in reply to Re^2: Transforming File Name Characters
in thread Transforming File Name Characters
You can try something along the following lines:
fixdir('d'); sub fixdir { my $dir = shift; opendir my $DH, $dir or die "$dir: $!"; while (my $f = readdir $DH) { next if grep $_ eq $f, qw/. ../; (my $new = $f) =~ s/[^a-zA-Z0-9_.]/_/g; die "$f: $new already exists.\n" if -e "$dir/$new" and $new ne + $f; print STDERR "Renaming: $f -> $new\n"; rename "$dir/$f", "$dir/$new"; fixdir("$dir/$new") if -d "$dir/$new"; } }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Transforming File Name Characters
by rfleisch (Initiate) on Mar 12, 2013 at 12:10 UTC | |
Re^4: Transforming File Name Characters
by rfleisch (Initiate) on Mar 14, 2013 at 17:53 UTC | |
by choroba (Cardinal) on Mar 14, 2013 at 18:06 UTC | |
by rfleisch (Initiate) on Mar 14, 2013 at 18:16 UTC | |
Re^4: REVISED - Transforming File Name Characters
by rfleisch (Initiate) on Mar 14, 2013 at 19:24 UTC | |
by choroba (Cardinal) on Mar 14, 2013 at 19:54 UTC | |
by rfleisch (Initiate) on Mar 15, 2013 at 15:18 UTC |
In Section
Seekers of Perl Wisdom