Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: rename files

by chester (Hermit)
on Aug 08, 2005 at 16:08 UTC ( #481924=note: print w/ replies, xml ) Need Help??


in reply to rename files

readdir is not my friend. If you use File::Find, you don't have to mess with relative vs. absolute pathnames. You can use $File::Find::name, which is a complete pathname. You don't have to worry about '..' and '.'. Etc. etc. Quite untested:

use File::Find; find(\&wanted, '/temp_gif'); sub wanted { return unless /^\d+\.gif$/i; (my $new_name = $File::Find::name) =~ s/(\d+)\.gif$/($1+398) . 'GIF'/ei; rename($File::Find::name, $new_name) or die $!; }


Comment on Re: rename files
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://481924]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2015-07-03 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls