Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
use strict;
use warnings;
use File::Find::Rule;
my %id_names = (
artist => 'ta',
year => 'ty',
date => 'ty', # alias
comment => 'tc',
album => 'tl',
title => 'tt',
tracknumber => 'tn',
genre => 'tg',
);
my $target_dir = 'mp3';
my @files = File::Find::Rule
->name('*.flac')
->file()
->in('.');
exit 0 unless @files;
mkdir $target_dir unless -d $target_dir;
for my $file (@files) {
my $q_file = quotemeta($file);
(my $mp3_file = $q_file) =~ s/flac/mp3/;
my @data = qx(metaflac --export-tags-to=- $q_file);
my %id;
foreach (@data) {
chomp;
my ($key, $value) = split('=', $_, 2);
$id{$key} = $value;
}
$id{tracknumber} .= '/' . scalar(@files) if (exists $id{tracknumber});
my $ids = '';
foreach(keys %id) {
$ids .= ' --' . $id_names{$_} . qq! "$id{$_}"!;
}
my $cmd = "flac -c -d $q_file | lame -V 0 $ids - $target_dir/$mp3_file";
qx($cmd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.