in reply to Re^3: Transforming File Name Characters
in thread Transforming File Name Characters
I have a question regarding this statement... sub fixdir { my $dir = shift; opendir my $DH, $dir or die "Not Found....$dir: $!"; while (my $f = readdir $DH) { next if grep $_ eq $f, qw/. ../; (my $new = $f) =~ s/[^a-zA-Z0-9_.]/_/g; next if ($new eq $f); <<<<<<<<<<<<< THIS ONE <<<<<<<<<<<< +<<<< while ( -e "$dir/$new") { $new.= "1"; } print STDERR "Renaming: $f -> $new\n"; rename "$dir/$f", "$dir/$new"; fixdir("$dir/$new") if -d "$dir/$new"; } } IF $f is the name of a directory and not a file won't that whole direc +tory get skipped????? Thanks -Ray
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Transforming File Name Characters
by choroba (Cardinal) on Mar 14, 2013 at 18:06 UTC | |
by rfleisch (Initiate) on Mar 14, 2013 at 18:16 UTC |