I searched extensively on this; I feel like this *must* have been posted somewhere and I'm just doing a bad job searching.
I'm trying to do something that I think is probably extremely basic but I lack the skill to be able to figure out how to do it on my own.
I have a command line utility that I want to run on a bunch of files.
If the command line utility had one input file and one output file (with *._in files being input and *.out being output), this is what I would use:
for %%a in (*._in) do command.exe -options "%%a" "%%~na.out"
However, this isn't the case. My utility specifies TWO input files, then outputs a combined result as ONE output file (with *.a._in and *.b._in as the two input files, and *.out as the output file).
With no knowledge of how to do it correctly, I would guess (very wrongly) that I want something like:
for %%a in (*.a._in) and for %%b in (*.b._in) do command.exe -options "%%a" "%%b" "%%~na.out"
Of course, this doesn't work.
Does anyone know how to do it correctly? (I hope this makes sense!)
I'm in a WinXP command environment, by the way.
FOR command with multiple variables
Moderator: DosItHelp
Re: FOR command with multiple variables
You haven't told us much detail - what exe is this so we can look at the help?
FWIW there are methods to parse the names but knowing the filename makeup helps to decide which method to use.
EG: are the any filenames like name.part2.a._in with periods in the rootname?
FWIW there are methods to parse the names but knowing the filename makeup helps to decide which method to use.
EG: are the any filenames like name.part2.a._in with periods in the rootname?
Re: FOR command with multiple variables
The Batch code below assume that for each file named *.a._in it must exist a file named *.b._in:
You may also do a merge of two lists with different named files.
Antonio
Code: Select all
for %%a in (*.a._in) do (
for %%b in ("%%~Na") do command.exe -options "%%a" "%%~Nb.b._in" "%%~Na.out"
)
You may also do a merge of two lists with different named files.
Antonio
-
- Posts: 3
- Joined: 22 Apr 2013 15:31
Re: FOR command with multiple variables
Thanks very much Aacini for that, that's exactly what I needed!
The only thing though, is that all the files have the same extension (they're .wav files actually
), so the in files are *.a.wav and *.b.wav, and the out files should be just *.wav. However, the outfiles end up being named *.a.wav, so they overwrite the original wav files. I could do "subdir\%%~na.wav", but the files will still need renamed to take the .a out.
You can't think of any way to do it in the batch file, can you? I guess that would actually involve editing one of the variables (stripping the .a out).
The only thing though, is that all the files have the same extension (they're .wav files actually

You can't think of any way to do it in the batch file, can you? I guess that would actually involve editing one of the variables (stripping the .a out).
Re: FOR command with multiple variables
Use this as the out filename: "%%~Nb.wav"
-
- Posts: 3
- Joined: 22 Apr 2013 15:31
Re: FOR command with multiple variables
foxidrive wrote:Use this as the out filename: "%%~Nb.wav"
I apologize for taking so long to reply. Life got in the way!

THANKS for the help! "Of course! I should have known!"
