 #! /usr/bin/perl

### WMA TO MP3 CONVERTER BY Seraphyn
### Start with perl wma2mp3.pl

$dir=`pwd`;

chop($dir);

opendir(checkdir,"$dir");

while ($file=readdir(checkdir)) {

$orig_file=$file;

if ($orig_file !~ /\.wma$/i) {next};

print "Checking file: $orig_file\n";

$new_wav_file=$orig_file;$new_wav_file=~s/\.wma/\.wav/;
$new_mp3_file=$orig_file;$new_mp3_file=~s/\.wma/\.mp3/;

$convert_to_wav="mplayer \"./$orig_file\" -ao pcm -aofile \"./$new_wav_file\"";
$convert_to_mp3="lame -h -b 192 \"./$new_wav_file\" \"./$new_mp3_file\"";
$remove_wav="rm -rf \"./$new_wav_file\"";

print "EXEC 1: $convert_to_wav\n";
$cmd=`$convert_to_wav`;
print "EXEC 2: $convert_to_mp3\n";
$cmd=`$convert_to_mp3`;
print "REMOVE WAV: $remove_wav\n";
$cmd=`$remove_wav`;
print "\n\n";

}

print "Done."; 
