Also strangely, I too wrote a Perl script last week to do the same thing. It generates Ogg Vorbis files if run as "flac2ogg", or MP3's if run as "flac2mp3", moving the tags in either case. I recently started ripping everything to FLAC, though I "compile" the files to MP3 for use with an Audiotron.
#!/usr/bin/perl
#
# flac2ogg / flac2mp3
#
# Converts FLAC files to Ogg Vorbis or MP3, depending on how
# this file is named.
#
# The encoded file is placed in the current directory, or optionally
# the directory specified with the -d option.
#
# Requires "metaflac", "oggenc", and "lame".
# MP3 quality setting
$preset = "standard";
# Ogg Vorbis quality setting
$q = "6";
use Getopt::Std;
use File::Basename;
use File::Spec;
$myname = (File::Spec->splitpath($0))[2];
getopts('td:', \%opt);
$dest = $opt{'d'} || ".";
$test = $opt{'t'} || 0;
# Convert each file name given on the command line.
while ($file = shift) {
($base, $path, $type) = fileparse($file, qr{\..*});
next unless ($type eq '.flac');
# Read in the tags
%tags = ();
open(METAFLAC, "metaflac --export-vc-to=- $file |") || die;
while (<METAFLAC>) {
chop;
($key, $value) = split('=');
$tags{uc($key)} = $value;
}
close(METAFLAC);
$flac = "flac -d -c -s $file";
if ($myname eq "flac2ogg") {
$tags = "\"=oggenc -q $q\"";
foreach $key (sort (keys %tags)) {
$tags .= " -c \"$key=$tags{$key}\"";
}
$encode = "oggenc -o $dest/$base.ogg -q $q -Q -c $tags -";
}
elsif ($myname eq "flac2mp3") {
$tags = "--ta \"$tags{'ARTIST'}\" " if ($tags{'ARTIST'});
$tags .= "--tl \"$tags{'ALBUM'}\" " if ($tags{'ALBUM'});
$tags .= "--tt \"$tags{'TITLE'}\" " if ($tags{'TITLE'});
$tags .= "--ty \"$tags{'DATE'}\" " if ($tags{'DATE'});
$tags .= "--tg \"$tags{'GENRE'}\" " if ($tags{'GENRE'});
$tags .= "--tn \"$tags{'TRACKNUMBER'}\" " if ($tags{'TRACKNUMBER'});
$tags .= "--tc \"lame --preset $preset\"";
$encode = "lame --quiet --preset $preset $tags - $dest/$base.mp3";
}
else {
exit 1;
}
if ($test) {
print "$flac | $encode\n";
}
else {
system("$flac | $encode");
}
}