| 1. |
Solve : Batch file - Multiple files to a command at once? |
|
Answer» Hello everyone, I am new to this forum. Secondly, is there a way to "DO" multiple commands within the FOR? FOR %%variable IN (set) DO ( command1 [command parameters] command2 [command parameters] commandn [command parameters] ) Beware of setting variables within the loop, you will need to use delayed expansion, or they won't work! Quote from: Dias de verano on September 23, 2008, 11:42:59 AM I think the separator for multiple input files is white space not a comma, and that implies that filenames which contain spaces need quote marks before and after. Not only white space, but commas, semi-colons and equal symbols are perfectly acceptable to the interpreter for use as separators. To guard against space embedded file names, the original code brackets each file NAME with quotes: Code: [Select]@echo off setlocal for %%x in (*.wav) do ( call set strCmd=%%strCmd%%,"%%x" ) set strCmd=%strCmd:~1% "g:\program files\flac\flac.exe" %strCmd% endlocal Quote from: Sidewinder on September 24, 2008, 04:14:42 AM Not only white space, but commas, semi-colons and equal symbols are perfectly acceptable to the interpreter for use as separators. I'm not talking about "the interpreter", I'm referring to flac.exe Oops! From what I could find out the OP's original code was correct. I didn't find any examples of how to send multiple files to flac.exe other then iterating a directory. Examples Flac FAQ Quote from: Sidewinder on September 24, 2008, 11:35:49 AM Oops! From what I could find out the OP's original code was correct. I didn't find any examples of how to send multiple files to flac.exe other then iterating a directory. Indeed. This suggestion from the FAQ, in answer to the question "why don't wildcards work?"... Quote for %F in (*.wav) do flac "%F" That is a command line example - double up the % signs if including in a batch. This implies that flac can only do 1 input file at a time, and that the answer to the OP's question, which was... Quote Problem is, each file was being sent one at a time. I need to find a way to send all the files in the directory to the program at once. ...is, "Sorry, there isn't a way to do that, because flac.exe won't accept multiple file names" I'd be interested to know why the OP WANTS to send multiple filenames all at once to flac.exe, SINCE even if it could accept them, it would still process them one after the other, and the result would be exactly the same as the solutions outlined above.Thanks for all the help you two, it is much appreciated. Indeed flac.exe can accept multiple files. White spaces are the seperators, each file name wrapped in quotes if it contains spaces. File names are to be listed after flac.exe and some options. Code: [Select]flac [various options] "filename1" "filename2" "filename3" As to why I want to do this; flac supports something CALLED "replay gain" http://replaygain.hydrogenaudio.org/. Each file will be encoded separately, however flac.exe must know which files are considered an album/group to properly calculate replay gain values for each individual track. I think sidewinders idea/code of stringing the file names together should work. I don't fully understand what exactly the code is doing, but I will try it out and report back. Thanks again. -edit- grammaticalBased on your latest post, this will give you white space separators on the command line: Code: [Select]@echo off for %%x in (*.wav) do ( call set strCmd=%%strCmd%% "%%x" ) "g:\program files\flac\flac.exe" [various options] %strCmd% Be sure to put in the various options before running the code. The code is designed as a batch file. Simply reporting back as I said I would. The code does indeed work. Thanks again. |
|