flac2mp3: batch flac to mp3 converter
November 4th, 2007Here is a quick script I whipped together to convert flac files to mp3. Its nothing fancy but it does the job. Doesnt require anything but flac and lame.
I was going to include a bunch of fancy id3 tag stuff but to be honest most of the id3 perl libraries out there arent that great to use. I may do something like that in the future though. Since I use quod libet which has a fantastic tagger built in, it isnt really an issue for me.
#!/usr/bin/perl
$lame_opt = "--preset extreme";
foreach (@ARGV) {
if (!($_ =~ /\.flac$/)) {
print "Skipping $_\n";
next;
}
`flac -d "$_"`;
$_ =~ s/\.flac$/.wav/;
$target = $_;
$target =~ s/\.wav$/.mp3/;
`lame $lame_opt "$_" "$target"`;
`rm "$_"`;
}