No idea without getting more familiar than I'd prefer with your SoX...
However, I'd try this:
As a test, use a single .wav file
for /r %%n in (justone.wav) do (
START "Left" C:\sox\sox.exe %%n -c 1 %%n.left.flac remix 1
START "Right" C:\sox\sox.exe %%n -c 2 %%n.right.flac remix 2)
And perhaps it'll run two instances simultaneously on a multi-processor machine. (Window title is "Left" or "Right")
Now - if this works, then try
@ECHO OFF
SETLOCAL
for /r %%n in (*.wav) do CALL :runsox "%%n"
GOTO :eof
:runsox
CALL :wait
START "%~1.left" C:\sox\sox.exe %~1 -c 1 %~1.left.flac remix 1
CALL :wait
START "%~1.right" C:\sox\sox.exe %~1 -c 2 %~1.right.flac remix 2
GOTO :eof
:wait
FOR /f %%c IN ('tasklist^|find /i /c "sox.exe"') DO SET running=%%c
IF %running% GEQ 6 timeout /t 5 >nul&GOTO wait
GOTO :eof
What this will do is execute the :runsox
procedure for each .wav
encountered, passing the .wav` name.
The runsox
procedure will call the wait
procedure - which I'll come to. When the WAIT
is finished, it'll put on the left sox, then wait again and put on the right, then return for the next filename until all's done. The %~1
in the names means 'the first parameter given to this routine, minus any enclosing quotes` - and that's the filename (%%n) provided by the CALL.
the wait
procedure finds out how many SOX.EXE
instances are running by passing a list of tasks from tasklist
through a find
filter to find the string sox.exe
/i
means regardless of case and /c
means output a count.
Running
therefore acquires a count of the instances of SOX
in progress. If that is greater than or equal to 6 (an arbitrary number - choose it to suit yourself. Best to leave one or two processors for other tasks, so 6 id good for an 8-processor machine) then a timeout of 5 seconds is executed and after 5 seconds the tasklist is examined again.
When there are fewer than 6 instances, the wait
procedure exits and the next task is started.
So - the WAIT
procedure waits until there are fewer than 6 SOX instances.
Change the 6 to suit your machinery and the 5 your aesthetics.
Edit: remove legacy closing-parenthesis