On Fri, 12 Aug 2011 13:42:36 -0400
Paul Davis <paul@email-addr-hidden> wrote:
> I strong, STRONGLY *STRONGLY recommend *not* doing file manipulations
> on audio files inside the shell. the proliferation of what once would
> have been considered "wierd" names for files makes this extremely
> "risky". it is very hard to prevent the shell from somehow getting
> stuff wrong when the filenames can include ' or " or $ themselves.
>
> use perl or python to do what you want, and thus avoid every issue
> with shell globbing etc.
You're right Paul, of course. So here is the hopefully safe Perl
version :
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
use File::Copy;
sub wanted {
my $input = $File::Find::name;
return unless (-f $input);
return unless ($input =~ m/\.mp3$/);
my $output = $input;
$output =~ s/\.mp3$/.m4a/;
File::Copy::copy($input, "/tmp/i.$$");
`ffmpeg -i /tmp/i.$$ -y -acodec libfaac -ab 192k /tmp/o.$$`;
rename("/tmp/o.$$", $output);
unlink("/tmp/i.$$");
}
File::Find::find({wanted => \&wanted}, '.');
-- David.
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-user
Received on Sat Aug 13 00:15:09 2011
This archive was generated by hypermail 2.1.8 : Sat Aug 13 2011 - 00:15:10 EEST