Can't cd to (./test/) test test test test: No such file or directory
at e:\path\myfiles\perl\filename_spaces2.pl line 7
The code is fine it is not completely "recursive" someone of you got some hint how to go down in every subdirectory?
If i start it a second time it is working ...
On first attempt the directory tree is (i got several space containing files below E:\temp:
#Perl should find spaces and replace them with "-"
#
use warnings;
use File::Copy;
use File::Find;
find(\&rename_txts, ".");
#Pfade ... find(\&rename_txts, "./txt2/");
sub rename_txts {
if (!/^\.+$/) {
my $new_name = $_;
$new_name =~ y/ /-/;
print "$File::Find::name to $new_name\n";
print "$_ \n";
move $_, $new_name;
}
}
The result is:
"E:\temp\test\test test test test"\Files with spaces ...
2nd attempt:
"E:\temp\test\test-test-test-test"Files-with-spaces...
so the 2nd (or depending on the number of subdirectories run is ok)
Thx for all your help so far
btw:
The purpose is to rename all the files on a network drive to proper names without spaces ...
|