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

Re: Mass file renaming

by rruiz (Monk)
on Jul 20, 2005 at 07:52 UTC ( [id://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.

HTH,
God bless you
rruiz

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found