Multiple File Conversions via Batch File

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?
 
J

Jon

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?

Change the 1 to a letter i and retry

Jon
 
J

Jon

Jon said:
Change the 1 to a letter i and retry

Jon

Sorry, that was a lazy response.

@ECHO OFF
FOR %%1 IN (%*) DO C:\"Program Files"\flac\bin\flac.exe -8 %%1

Jon
 
P

Phil Robyn

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?

- - - - - - - - begin screen capture WinXP Pro SP2 - - - - - - -
C:\cmd>for %a in (\windows\Media\*.wav) do @echo/"C:\Program
Files\flac\bin\flac.exe" -8 "%~fa"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\chimes.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\chord.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\ding.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\notify.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\recycle.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\ringin.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\ringout.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\start.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\tada.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Balloon.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Battery Critical.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Battery Low.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Critical Stop.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Default.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Ding.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Error.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Exclamation.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Hardware Fail.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Hardware Insert.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Hardware Remove.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\windows xp
information bar.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Logoff Sound.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Logon Sound.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Menu Command.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Minimize.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Notify.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\windows xp
pop-up blocked.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Print complete.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Recycle.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Restore.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Ringin.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Ringout.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Shutdown.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Start.wav"
"C:\Program Files\flac\bin\flac.exe" -8 "C:\WINDOWS\Media\Windows XP
Startup.wav"
- - - - - - - - end screen capture WinXP Pro SP2 - - - - - - - -
(watch out for line wrap)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top