I thought I'd submit a fixed version of the original perl script:
Code:
#!/usr/bin/perl
#Searches a directory for mp3 files,
#normalizes the sound and then
#creates an .ogg file.
#$fromExt and $toExt can be used to change
#the default conversions. Remember
#to change the oggenc line as well.
#Modified by WARnux but still has no warrenty
$fromExt='mp3';
$toExt='ogg';
$tmpDir='/tmp/NormalizeAndConvertTmp/';
$outDir='./';
#'./Normalized_'.$toExt.'/';
mkdir($tmpDir);
mkdir($outDir);
$dir=`pwd`;
chop($dir);
opendir(checkdir,"$dir");
while($file=readdir(checkdir))
{
$orig_file= $file;
#/in here matches a regex/
#$ makes it match the end of the string and i is for case insensitive
if($orig_file !~ /\.$fromExt$/i)
{next};
print "Checking file: $orig_file\n";
$temp= $orig_file;
#s is for substitute; it will replace the first match with the second string
$temp =~ s/\.$fromExt$/\.wav/i;
$out= $orig_file;
$out =~ s/\.$fromExt$/\.$toExt/i;
$convert1= "mplayer \"./$orig_file\" -vc null -vo null -af volnorm -ao pcm:file=\"$tmpDir$temp\"";
$convert2= "oggenc \"$tmpDir$temp\" -o \"$outDir$out\"";
#"lame -h \"$tmpDir$temp\" \"$outDir$out\"";
$remove_temp= "rm -rf \"$tmpDir$temp\"";
print "Converting to .wav: $convert1\n";
$cmd= `$convert1`;
print "Converting to .ogg: $convert2\n";
$cmd= `$convert2`;
print "Removing .wav: $remove_temp\n";
$cmd= `$remove_temp`;
print "\n\n";
}
rmdir($tmpDir);
print "Done.\n\n";
The original had a few issues if files were .MP3 or .mp3.mp3 and I added scalability and other improvements. Oh, and by default, it converts mp3 not wma but that's easily changed.