#!/usr/bin/perl $lameopts = "-m s --vbr-new -b 32 -B 320 -V 2 -o --add-id3v2 --silent"; $nice = "nice -n 19"; # Default to low priority, set to "" to disable; $switch = $ARGV[0]; $switch2 = $ARGV[1]; if ($switch eq "-R") { if ($switch2 eq "-r") { $switch = $switch2; } $cwd = `pwd`; $find = `find $cwd`; @prefiles = split("\n",$find); $n = 0; foreach $file (@prefiles) { if ($file =~ m/\.wma/) { @files[$n] = $file; $n++; } } } else { $ls = `ls *.wma`; @files = split("\n",$ls); } foreach $file (@files) { $outfile = $file; $outfile =~ s/\.wma/\.mp3/; $mplayeroutput = `$nice mplayer "$file" -ao pcm -quiet`; @mplayer = split("\n",$mplayeroutput); foreach $line (@mplayer) { if ($line =~ m/name:/) { $title = $line; $title =~ s/ name: //; } if ($line =~ m/author:/) { $artist = $line; $artist =~ s/ author: //; } } print "\n\nFile $file...\n"; if ($artist) { print "Artist: $artist\n"; } if ($title) { print "Title: $title\n"; } print "Proceeding to encode...\n"; open(LAME, "$nice lame audiodump.wav - $lameopts --tt \"$title\" --ta \"$artist\" | "); while () { $lamemp3 .= $_; } close(LAME); print "Encoding Complete.\n"; open(MP3, "> $outfile"); binmode($file); print MP3 $lamemp3; $size = length($lamemp3); $lamemp3 = ""; close(MP3); print "$outfile written successfully ($size bytes).\n"; if ($switch eq "-r") { print "Removing $file...\n"; unlink($file); print "$file deleted.\n\n"; } else { print "\n"; } unlink("audiodump.wav"); }