Saturday, February 25, 2006

wma to mp3

I found an old script on to convert wma's to mp3's.
I had to make a minor change to get it working with the latest version
of mplayer.

Requirements: Lame, mplayer.

To save the script, do this:

gedit /usr/bin/wma2mp3

then copy paste the code.

Then type:

chmod a+x /usr/bin/wma2mp3

If you don't have sudo, then just remove sudo and run the commands as

Here is the code:


current_directory=$( pwd )
#remove spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done
#remove uppercase
for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
#Rip with Mplayer / encode with LAME
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao
pcm:waveheader $i && lame -m s audiodump.wav -o $i; done
#convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3"; done
rm audiodump.wav

The script runs without any arguments, and it will convert all files in the folder.

Warning: All files will be overwritten

No comments: