Running a given number of functions at once

@async ebook-convert.exe {filepath$} {filepath$|ext=mobi}

ebook-convert.exe from Calibre package converts between any supported document types, in above case to .mobi.
I use it in context menu of .rtf files as ConvertToMOBI.

So I have a 100 .rtf files selected. If I choose ConvertToMOBI from context menu it will run a 100 instances of ebook-convert.exe.
100 instances at once is overkill for my system, but any number other than number of logical CPU cores is unoptimal (ebook-convert.exe has only one working thread).

Ideal situation would be running a given maximum of instances at once. I.e. if given maximum is 4, then it would run a four instances, if 1st, 2nd, 3rd, or 4th instance would complete its job, then 5th would be launched and so on.

Is there any way to achive this goal?

Directory Opus 10.0.2.1.4344 x64
Vista Ultimate x64

I can't think of a simple way to do with Opus on its own.

I seem to remember seeing a small tool that could be passed a list of files/commands and run through them spread across multiple CPUs, but I can't seem to find it, if it exists and I'm not thinking of something else.

I'll add this into the ideas list as it would be useful in a few situations and multiple CPUs are the norm these days.

Hi,

head over to sysinternals.com and grab "psexec". This may do what you want.

I don't think psexec's -a argument is useful here.

As far I can tell, that just sets the processor affinity for the target process. The command will still only be run once and the only difference is which CPU(s) that process is likely to use. If it's a single-threaded process then it will still only use one CPU, so the net result is just changing which single CPU it uses.

Explicitly changing the processor affinity is rarely needed or useful. With some old programs / drivers it can solve problems in code that crashes or runs slowly if its thread(s) don't always run on the same CPU, but that's very rare in these days where multiple CPUs are the norm, unless you're running an old game or something similar.

I think running n threads simultaneously could be extremely helpful. Rotating/resizing large number of images could be much faster then (and this is just one example).