#!/usr/bin/perl -w use strict; my $album = $ARGV[0]; if(not defined $album) { die "Need to specify directory of album."; } $album =~ s|/$||; my $t = time(); my $tmp_dir = "/var/tmp/recreate-cd-from-flac-tmp-$t"; if(-d $tmp_dir) { die "tmp directory shouldn't exist"; } else { system("mkdir $tmp_dir"); } my $wav_files = ""; my @files = `find "$album" -name *.flac | sort`; foreach my $file (@files) { chomp($file); print "$file\n"; my $output_file = $file; $output_file =~ s/$album/$tmp_dir/; $output_file =~ s/\.flac/\.wav/; print "$output_file\n"; $wav_files .= "\"$output_file\" "; system("flac -d \"$file\" -o \"$output_file\""); } #my $cmd = "cdrecord -v speed=1 dev=1,0,0 -dao -audio dev=/dev/cdwriter $tmp_dir/*\n"; my $cmd = "cdrecord -v speed=1 dev=1,0,0 -dao -audio dev=/dev/cdwriter $wav_files\n"; print "\n$cmd\n\n"; system($cmd); system("rm -rf \"$tmp_dir\"");