Convert WMA to MP3
Computer System/Software / 2009/03/21 10:10
I have been using several Windows applications to convert a music file. Since I got many WMA files recently, I wanted to convert them in my Linux computer.
It was much easier to convert them in Linux than Windows.
You just need to install mplayer, lame, and ffmpeg (optional).
It was much easier to convert them in Linux than Windows.
You just need to install mplayer, lame, and ffmpeg (optional).
# yum install mplayer lame ffmpeg
Save the following code to wma2mp3.sh. Then, simply run wma2mp3.sh in the same directory of the wma files you want to convert.
# sh wma2mp3.sh
#! /bin/sh
# wma to mp3 shell scriptmkdir -p converted_mp3
cp *.wma converted_mp3
cd converted_mp3# How many files to make the progress bar
PROGRESS=0
NUMBER_OF_FILES=`find -iname "*.wma"`#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#edit this if you need to change the options for lame encoding to mp3
FORMAT='lame -h -m s'#Rip with Mplayer / encode with LAME
for i in *.wma ; do
echo "$PROGRESS";
echo "# Re-Coding $i";
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader $i && $FORMAT audiodump.wav -o $i;
done#convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3";
donerm audiodump.wav
exit 0
