Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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.

HTH,
God bless you
rruiz


Comment on Re: Mass file renaming
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2014-09-02 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (21 votes), past polls