Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: File::Find: Problem with renaming folders recursively

by larus (Acolyte)
on Mar 23, 2009 at 12:39 UTC ( #752568=note: print w/replies, xml ) Need Help??


in reply to File::Find: Problem with renaming folders recursively

I found a solution, this works fine:
#!/bin/perl use warnings; use strict; use File::Find; use File::Copy; my $path = $ARGV[0]; my $from = $ARGV[1]; my $to = $ARGV[2]; die "You must supply a full directory path" unless (-e $path && -d $pa +th); finddepth(\&renamedir, "$path"); # find -> finddepth sub renamedir { return if -f $_; return if /^\./; my $new_name = $_; $new_name =~ s/$from/$to/g; move($_, $new_name) or die $!; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://752568]
help
Chatterbox?
and the monks are mute...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2017-02-19 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (293 votes). Check out past polls.