Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 pondering the Monastery: (8)
As of 2015-07-06 06:46 GMT
Find Nodes?
    Voting Booth?

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

    Results (70 votes), past polls