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?

Mambo4
  • 182
  • 7
  • 17

2 Answers2

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.

MSZ
  • 80
  • 4
0

Try this:

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

Just replace C:\Wavs with your path.

Bali C
  • 30,582
  • 35
  • 123
  • 152
  • 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 '12 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 '12 at 19:31