#!/usr/bin/perl use strict; use warnings; my $flac = 'flac'; my $metaflac = 'metaflac'; my $lame = 'lame'; my $infile; my $outfile; my %tags; for (@ARGV) { s/"/\"/; if (s/(.+\.flac)/-/) { $infile = $1; } elsif (s/(.+\.mp3)//) { $outfile = $1; } } if (not defined $outfile) { ($outfile = $infile) =~ s/\.flac$/\.mp3/; } open METADAT, qq!$metaflac --list "$infile" |!; while() { if (/ALBUM=(.+)/) { $tags{'album'} = $1; } elsif (/ARTIST=(.+)/) { $tags{'artist'} = $1; } elsif (/TITLE=(.+)/) { $tags{'title'} = $1; } elsif (/TRACKNUMBER=(\d+)/) { $tags{'tracks'} = $1; } } close METADAT; my $lametagstr = qq!--tt "$tags{'title'}" --ta "$tags{'artist'}" --tl "$tags{'album'}" --tn "$tags{'tracks'}"!; print "Options: $lametagstr @ARGV\n"; print "Infile: $infile\n"; system(qq!$flac -c -d "$infile" | $lame $lametagstr @ARGV "$outfile"!);