G
Guest
Hello,
I am attempting to convert multiple .wav files to the .flac format via a batch script. I know that this can be done with numerous software implementations automatically for me; however, i am interested to understand how to create a script to perform my purpose and since this function is useful, what the hey! I am rather new to batch files but would appreciate any help. TIA
My process thus far has been the following:
I edited the file type .wav via Tools>Folder Options>File Types I added an option for "Encode to Flac" and pointed this at my "flac-convert.bat %1"
Essentially this works fine; The script runs and encodes one file with ease. At this point my script was:
@ECHO OFF
C:\"Program Files\flac\bin\flac.exe -8 %1
However, when I highlighted multiple .wav files in Explorer and click my "Encode" option multiple instances of the batch file are run. I attempted to solve this with the following code:
@ECHO OFF
:LOOP
FOR %%1 IN (.) DO C:\"Program Files"\flac\bin\flac.exe -8 %%1
SHIFT
IF "%1" == "" GOTO END
GOTO LOOP
:END
When I ran this code I hit another stumbling block. The code was parsing the %1 differently than it had in my original instance where flac was run directly. The filenames contained are something like My_alto-sax_solo.wav When I ran the first script this was parsed fine and the wav file was encoded; but, when the flac.exe was run from within the FOR loop the input file is claimed to be invalid.
So my question is two part:
1)Understanding the parsing of text within a Batch File:
How does passing a command within a FOR alter the way arguments are passed to it?
and
2) Is it possible to only run one instance of the batch file via some setting within Windows?
I am attempting to convert multiple .wav files to the .flac format via a batch script. I know that this can be done with numerous software implementations automatically for me; however, i am interested to understand how to create a script to perform my purpose and since this function is useful, what the hey! I am rather new to batch files but would appreciate any help. TIA
My process thus far has been the following:
I edited the file type .wav via Tools>Folder Options>File Types I added an option for "Encode to Flac" and pointed this at my "flac-convert.bat %1"
Essentially this works fine; The script runs and encodes one file with ease. At this point my script was:
@ECHO OFF
C:\"Program Files\flac\bin\flac.exe -8 %1
However, when I highlighted multiple .wav files in Explorer and click my "Encode" option multiple instances of the batch file are run. I attempted to solve this with the following code:
@ECHO OFF
:LOOP
FOR %%1 IN (.) DO C:\"Program Files"\flac\bin\flac.exe -8 %%1
SHIFT
IF "%1" == "" GOTO END
GOTO LOOP
:END
When I ran this code I hit another stumbling block. The code was parsing the %1 differently than it had in my original instance where flac was run directly. The filenames contained are something like My_alto-sax_solo.wav When I ran the first script this was parsed fine and the wav file was encoded; but, when the flac.exe was run from within the FOR loop the input file is claimed to be invalid.
So my question is two part:
1)Understanding the parsing of text within a Batch File:
How does passing a command within a FOR alter the way arguments are passed to it?
and
2) Is it possible to only run one instance of the batch file via some setting within Windows?