Peters Flexible RenAmiNg Kit (PFrank) Forum Index Peters Flexible RenAmiNg Kit (PFrank)
Support and Discussion Site for the PFrank File/Folder Renaming Tool (http://www3.telus.net/pfrank)
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need to Add leading Zeros

 
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> Regular Expressions
View previous topic :: View next topic  
Author Message
kc27



Joined: 23 May 2007
Posts: 9

PostPosted: Wed Aug 08, 2012 6:48 pm    Post subject: Need to Add leading Zeros Reply with quote

I have a folder that contains files named in this fashion:

62-01p00-01.log
30722-01p00-01.log

I would like to be able to search for all files that are less than 5 digits before the first dash, and add leading zeros to bring it up to a 5 digit number. So that

62-01p00-01.log would become 00062-01p00-01.log but PFrank would ignore files named 30722-01p00-01.log because it is already 5 digits

Does anyone have any ideas on how to accomplish this?
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Fri Aug 10, 2012 3:16 pm    Post subject: Reply with quote

There is a pre-defined regex called 'Pad Numbers to 5 digits' that can be used as a template.

I came up with the follwoing modified version that might work for you.l Copy and paste the following lines into the Custom renaming creator window (do not include the single quotes):

Row: 1
Search: '(?x1) ^([0-9])([-].*) # pad 1 digit number'
Replace: '0000\g<1>\2'
Row: 2
Search: '(?x1) ^([0-9]{2,2})([-].*) # pad 2 digit number'
Replace: '000\g<1>\2'
Row: 3
Search: '(?x1) ^([0-9]{3,3})([-].*) # pad 3 digit number'
Replace: '00\g<1>\2'
Row: 4
Search: '(?x1) ^([0-9]{4,4})([-].*) # pad 4 digit number'
Replace: '0\g<1>\2'


Hope that helps,

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> Regular Expressions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own Video Sharing Site

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com