Hello you helpful folk! Please look at my script and tell me what I am doing wrong! I am cleaning the names of my music files from unnecessary symbols, and the cleaning works fine, however the perl rename function fails to do the actual renaming. I tried to rename a file in the same dir using strings instead of variables and that works!! But it seems I need to get it to work with vars as well. Can anyone give me a clue? Thanks!!
[CODE=perl]
$dirname = "C:/folder";
opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
$neu = $file;
print $neu;
print "\n";
$neu =~ tr/['&a-zA-Z]/ /c;
print $neu;
print "\n";
$neu =~ tr/A-Z/a-z/;
print $neu;
print "\n";
$neu =~ s/\b(\w+)\b/ucfirst($1)/ge;
print $neu;
print "\n";
$neu =~ s/Mp/.mp3/;
$neu =~ s/Wav/.wav/;
$neu =~ s/Fl/.flv/;
$neu =~ s/Vob/.vob/;
$neu =~ s/'S/'s/g;
print $neu;
print "\n";
$neu =~ tr/ //d;
print $neu;
print "\n";
rename ("$file", "$neu");
}
#rename "C:/folder/03-kt_tunstall-one_day.mp3", "C:/folder/NEW NAME.mp3";
closedir(DIR);[/CODE]
[CODE=perl]
$dirname = "C:/folder";
opendir(DIR, $dirname) or die "can't opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
$neu = $file;
print $neu;
print "\n";
$neu =~ tr/['&a-zA-Z]/ /c;
print $neu;
print "\n";
$neu =~ tr/A-Z/a-z/;
print $neu;
print "\n";
$neu =~ s/\b(\w+)\b/ucfirst($1)/ge;
print $neu;
print "\n";
$neu =~ s/Mp/.mp3/;
$neu =~ s/Wav/.wav/;
$neu =~ s/Fl/.flv/;
$neu =~ s/Vob/.vob/;
$neu =~ s/'S/'s/g;
print $neu;
print "\n";
$neu =~ tr/ //d;
print $neu;
print "\n";
rename ("$file", "$neu");
}
#rename "C:/folder/03-kt_tunstall-one_day.mp3", "C:/folder/NEW NAME.mp3";
closedir(DIR);[/CODE]
Comment