Last change
on this file since 29657 was 29657, checked in by jmt12, 9 years ago |
little script to convert a directory of MP3s into WAVs
|
-
Property svn:executable
set to
*
|
File size:
1.0 KB
|
Rev | Line | |
---|
[29657] | 1 | #!/usr/bin/perl
|
---|
| 2 |
|
---|
| 3 | use strict;
|
---|
| 4 | use warnings;
|
---|
| 5 |
|
---|
| 6 | print "\n===== Convert MP3s to WAVs =====\n";
|
---|
| 7 | print "Converts a directory of MP3s into a directory of WAVs, replacing old\n";
|
---|
| 8 | print "filenames with simple numbering.\n\n";
|
---|
| 9 |
|
---|
| 10 | if (!defined $ARGV[0] || !-d $ARGV[0])
|
---|
| 11 | {
|
---|
| 12 | print "Error! Missing input directory or directory doesn't exist\n";
|
---|
| 13 | print "usage: convert_mp3_to_wav.pl <input directory> <output directory>\n\n";
|
---|
| 14 | exit();
|
---|
| 15 | }
|
---|
| 16 | if (!defined $ARGV[1] || !-d $ARGV[1])
|
---|
| 17 | {
|
---|
| 18 | print "Error! Missing output directory or directory doesn't exist\n";
|
---|
| 19 | print "usage: convert_mp3_to_wav.pl <input directory> <output directory>\n\n";
|
---|
| 20 | exit();
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | opendir(DH, $ARGV[0]) or die "Failed to open directory for reading: ./import.mp3";
|
---|
| 24 | my @files = readdir(DH);
|
---|
| 25 | closedir(DH);
|
---|
| 26 |
|
---|
| 27 | my $counter = 0;
|
---|
| 28 | foreach my $file (@files)
|
---|
| 29 | {
|
---|
| 30 | if ($file =~ /\.mp3$/)
|
---|
| 31 | {
|
---|
| 32 | $counter++;
|
---|
| 33 | my $cmd = 'ffmpeg -i "' . $ARGV[0] . '/' . $file . '" "' . $ARGV[1] . '/' . sprintf("%04d", $counter) . '.wav"';
|
---|
| 34 | print $cmd . "\n";
|
---|
| 35 | `$cmd`;
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | print "Complete!\n\n";
|
---|
| 40 |
|
---|
| 41 | exit;
|
---|
| 42 | 1;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.