Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: rename files

by SimonClinch (Chaplain)
on Aug 08, 2005 at 13:43 UTC ( #481875=note: print w/ replies, xml ) Need Help??


in reply to rename files

The most pertinent issues are:

(1) split has no default second argument, so the $_ needs to be explicit.

(1) at the least under unix, you could get an error trying to rename . and .. (the current and parent directories). To avoid that, replace the readdir with

grep !/^\./, readdir
(2) but, just in case there are yet more files in the directory that you don't want to rename, you might consider instead:
grep /^\d+\.gif/, readdir

(3) the '.' operator in the arguments to rename will not produce a literal '.' as has already been hinted at.

Update:

(4) it is possible but suspicious that you expect to have a mount point at '/temp_gif' ... should this not be './temp_gif'?

(5) if so, then when that is corrected, the fix suggested by others of putting the relative or full path in front of the arguments to rename will become able to function.

One world, one people


Comment on Re: rename files
Select or Download Code
Re^2: rename files
by Fletch (Chancellor) on Aug 08, 2005 at 13:46 UTC
    (1) split has no default second argument, so the $_ needs to be explicit.

    Erm . . .

    split /PATTERN/,EXPR,LIMIT split /PATTERN/,EXPR split /PATTERN/ split Splits a string into a list of strings and returns [ . . . ] + If EXPR is omitted, splits the $_ string.

    --
    We're looking for people in ATL

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2014-08-22 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (168 votes), past polls