Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

Try this:

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

Just replace C:\Wavs with your path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top