Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 $!; }


Comment on Re: File::Find: Problem with renaming folders recursively
Download Code

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 web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2014-08-27 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (252 votes), past polls