Hi All,
I created a script that renames a dir of MP3 files... Everything is working well except when I try to write the new files to a directory. I thought I could print to a dirhandle, apparently not.. :~) Maybe I need to mv the $newfile...? not sure... Any help would be greatly appreciated!
Thanks!
Brian
#!/usr/bin/perl
use strict; use warnings;
my $mp3_dir = "/home/bvolk/Dell/Shared/Mp3_to_wav"; opendir (FILES, $mp3_dir) || die "Couldn't open $mp3_dir: $! \n";
my @files = grep { !/^\.\.?$/ } readdir FILES;
closedir FILES;
my $new_mp3_dir = "/home/bvolk/Music/MP3_files"; opendir (NEWDIR, $new_mp3_dir) || die "Couldn't open $new_mp3_dir: $! \n";
foreach my $file(@files){
my($newfile) = lc $file; # Lower case all file names
$newfile =~ s/ /_/g; # Replace spaces w/ underscores
$newfile =~ s/&/and/g; # Replace ampersands
$newfile =~ s/\'//g; # Remove apostrophes
$newfile =~ s/(\(|\))//g; # Remove parenthesis
$newfile =~ s/[\-]//g; # Remove dashes
$newfile =~ s/,//g; # Remove commas
print NEWDIR "$newfile \n";
}
closedir NEWDIR;
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>