Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: rename files

by izut (Chaplain)
on Aug 08, 2005 at 15:12 UTC ( #481909=note: print w/ replies, xml ) Need Help??


in reply to rename files

The problem is the foreach passes to block just the filename (1.gif, 3.gif). You should concatenate the path (/temp_gif) and the filename (3.gif) when rename()ing.

$dir = "/temp_gif"; opendir(DH, $dir) or die $!; foreach (readdir DH) { next if /^\.?\.$/; ($number, $gif) = split /\./; print "$number\n"; $numbers_replace = int($number) + 338; rename("$dir/$_", "$dir/$numbers_replace.GIF") or warn $!; }


Igor S. Lopes - izut
surrender to perl. your code, your rules.


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://481909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (15)
As of 2014-09-16 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (46 votes), past polls