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

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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2016-02-11 04:38 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (359 votes), past polls