Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: rename files

by SimonClinch (Deacon)
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.


(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

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://481875]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2018-02-20 00:17 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (266 votes). Check out past polls.