All pastes #35217 Raw Edit

Miscellany

public text v1 · immutable
#35217 ·published 2005-12-29 22:52 UTC
rendered paste body
#!/usr/bin/perl

use warnings;
use strict;

# produces an array of filenames ending in .flac in the current dir
my @flacs = grep { /\.flac$/ } map { s/[\r\n]//g; $_ } `ls`;
# produces an array of the filenames in @flac without the file suffix
my @filenames =  map { s/\.flac$//g; $_ } @flacs;
my $n_of_flacs = @flacs;
print "detected $n_of_flacs flac files";

foreach $file (@filenames) {
  my %fileinfo;
  my $mp3 = "$file.mp3";
  foreach (`metaflac $file.flac --export-tags-to=-`) { 
    chomp;
    my ($key, $value) = split /=/;
    $fileinfo{$key} = $value;
  }
  print "converting $file.flac into $file.mp3";
  `flac -c -d $file.flac | lame -h - $file.mp3`;
  `id3 -t "$fileinfo{title}" -a "$fileinfo{ARTIST}" -A "$fileinfo{ALBUM}" $file.mp3`;
}