Batch file for mp3 encoding

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Ant_222
Posts: 2
Joined: 10 May 2008 10:33

Batch file for mp3 encoding

#1 Post by Ant_222 » 10 May 2008 10:44

Hi, I'd like to create an MSDOS *.bat file that'd take all the *.wav files in the current directory and for each of them call

Code: Select all

lame.exe [options] filename.wav filename.mp3

In other words, my problem is that I can't figure out how rename *.wav to *.mp3 inside a FOR loop because the SET command seems to be ingnored...

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

#2 Post by jeb » 12 May 2008 15:56

Hi,

Code: Select all

for %%a in (*.wav) DO lame.exe /myoptions %%a %%~na.mp3


should work.

The trick is %%~n which results in the filename (without) extension.

jeb

Ant_222
Posts: 2
Joined: 10 May 2008 10:33

#3 Post by Ant_222 » 13 May 2008 06:53

Many thanks!

It turns out that lame automatically renames filename.wav into filename.mp3 if the output file is not specified.
But just for the sacred MSDOS knowledge, thnx. And why the SET command called inside a FOR loop doesn't seem to work? Should I provide an example?

Anton

Post Reply