2

I would like to write a batch file that runs the cmd line " lame.exe [options] [infile] [outfile]" on a folder of .wav files.

something like

FOR %%f IN (dir *.wav) DO (lame.exe -V0 -h %%f.wav %%f.mp3)

of course that's wrong but...how do I generate the correct [infile] [outfile] arguments for this?

2 Answers 2

5

I tried the above, and got all kinds of syntax errors. The problem happens if you have spaces in your file names. Thus, this would be a more generally useful batch file:

for %%i in (*.wav) do "D:\yourdir\lame.exe" -V 6 --vbr-old --resample 22.05 "%%i" "%%~ni.mp3"

Note, in my example I'm also using lower quality for compressing audiobook files for minimum size, and so I can drop the batch file in my wav folder, I put the full path to lame negating the need to set a path environment variable. The key change is quotes around the filename arguments.

1
  • I =1'd this because wrapping w/quotes is indeed what I ended up doing. Thanks!
    – Mambo4
    Apr 17, 2012 at 16:09
0

Try this:

for %%i in (C:\Wavs\*.wav) do lame.exe -V0 -h %%i %%~nI.mp3

Just replace C:\Wavs with your path.

2
  • I adpated something similar form another .bat: for %%f in (*.wav) do c:\progra~2\lame\lame.exe -V0 -h "%%f" "%%f.mp3" but it generates inputfile.wav.mp3, which is messy. can i get it to change %%f into from inputfile.wav to inputfile.mp3?
    – Mambo4
    Mar 23, 2012 at 17:23
  • The %%~ni returns the filename without the extension, then you can add the extension you want on the end.
    – Bali C
    Mar 23, 2012 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.