Tuesday, February 26, 2013

Shell script for converting WMA to MP3

Source: Internet

#! /bin/sh
# wma to mp3 script

mkdir -p converted_mp3
cp *.wma converted_mp3
cd converted_mp3

# How many files to make the progress bar
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;

#convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3";

rm audiodump.wav

exit 0

No comments: