Padding Numbers

A swapping-ground for Regular Expression syntax

Padding Numbers

Postby biglizard » Thu May 25, 2006 5:15 pm

Hi Guys,

I need some help please with padding numbers using a regular expression. I often have files that could be named as follows:
IMG1.JPG
IMG10.JPG
IMG100.JPG
IMG1000.JPG

Due to the way the sorting occurs I need to have the files padded to the length of the highest number, in this example 4 digits. So
IMG1 would become IMG0001.JPG
IMG10 would become IMG0010.JPG
IMG100 would become IMG0100.JPG
IMG1000 would remain as IMG1000.JPG

I can achieve this using the numbering function but need to do it in several passes, I would ideally like to achieve this in one pass and assume a regexp is the answer.

Thank you in anticipation.
biglizard
 
Posts: 12
Joined: Wed Jun 22, 2005 8:55 pm

Postby Admin » Thu May 25, 2006 6:59 pm

Hi,

No, I don't think a regexp is the answer. At least, not for the entire job.

Shy do you have to do multiple passes with the autonumber option? This should be possible in a single pass (or possibly in combination with a RegExp, depending upon some more examples....)



Jim
Admin
Site Admin
 
Posts: 1484
Joined: Tue Mar 08, 2005 8:39 pm

Postby biglizard » Thu May 25, 2006 9:49 pm

Hi Jim,

I had hoped the example I provided would be enough. When I try to pad to say 4 numbers i have to do it in a few passes. For example, to change IMG1 to IMG0001 I can use the pad option in the numbering section. However, if I apply this to say IMG10 it will change it to IMG00010, when what I need it to do is change it to IMG0010.

I hope this makes sense.
biglizard
 
Posts: 12
Joined: Wed Jun 22, 2005 8:55 pm

Postby Admin » Thu May 25, 2006 10:01 pm

Hi,

Yes, this was why I was after more examples.

With the example you've given, why not remove the numbers all together? So you end up with a filename of just IMG. Then the AutoNumber will work correctly, e.g. IMG0001, IMG0002, ..., IMG0010...

This should work.



Jim
Admin
Site Admin
 
Posts: 1484
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions