Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Mass file renaming

by rruiz (Monk)
on Jul 20, 2005 at 07:52 UTC ( #476401=note: print w/ replies, xml ) Need Help??

in reply to Mass file renaming

Once you have the file name in a var like:

$filename = 'aa22200010001.png';

You can use either:

$filename =~ s/(\d{3})(\d{6})(\d{2})/sprintf("%03d%06d%02d", $1,$2+1,$ +3)/e;

Or (as pointed by BrowserUK):

$filename =~ s/(\d{11})/$1 + 100/e;

Just note that if your file name var contains the path to the file, and one of the directories in the path contains a similar name (ie. eleven consecutive digits, as in: '/tmp/0123456789019/22200010001.png'), you will have to modify the regexp to take it into account and the replacement part will/may not be so simple.

God bless you

Comment on Re: Mass file renaming
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2015-07-30 09:13 GMT
Find Nodes?
    Voting Booth?

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

    Results (270 votes), past polls