reg expression padding number seq

A swapping-ground for Regular Expression syntax

reg expression padding number seq

Postby zimbot » Mon Oct 01, 2007 8:18 pm

Friends,
I have many jpegs that I wish to rename.
Tese are jpgs from a :30 video 1 per second so order is important.
these have names like
99922c1_1.jpg
99922c1_2.jpg
...
99922c1_10.jpg
99922c1_11.jpg
...
99922c1_20.jpg
99922c1_21.jpg

and on like that til 30
and I wish to have the nums

be more like
99922c1_001.jpg
99922c1_002.jpg
...
99922c1_010.jpg

-----------

I am doing a reg expression like so

([0-9]+c[0-9]+_)([0-9]+)

match pass 1
\10\2

yields : 99922c1_01.jpg .. 99922c1_020.jpg
that is good but now i must so a second pass on the 1-9 fellows

([0-9]+c[0-9]+_)([0-9]+)

match pass 2 , on the 01-09

\100\2

and I get 99922c1_001.jpg , 99922c1_002.jpg , 99922c1_009.jpg


so my Q : is there a way to "test" the string length of group2

if the string len is 1 ( as in 99922c1_1.jpg ) pad w 2 zeros " 00 "
if the string len is 2 ( as in 99922c1_10.jpg ) pad w zero "0"

If I can find a single ( not 2 step ) solution I will be reaching for the donate button.

also, I may do this w command line _ I only now have heard that there is a commandline vers of Bulk Rename Utility.

and may I say Bulk rename Utility is a darn fine software.
Likely it can do exactly what i need - i am just not real good at reg exp
zimbot
 
Posts: 3
Joined: Mon Oct 01, 2007 6:16 pm

Postby Admin » Tue Oct 02, 2007 7:16 am

It sounds like you have over-complicated your approach. Why not use the Autonumber facility, and forget Regular Expressions.

Use the Remove facility to remove from position 9 onwards (e.g. after the "-") and then add an autonumber, padded to three places.

Your example doesn't show what the NEXT filename groups are called, but my guess is that you also want to specify "break at position 7" on the Autonumber to foirce it to start from 1 again.

You can do all this in one pass.


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

Postby BRUFolio » Tue Oct 02, 2007 11:06 am

Also, you will want 1-9 to be 01-09,,,,
BRUFolio
 
Posts: 45
Joined: Tue Feb 21, 2006 12:05 pm

Postby zimbot » Tue Oct 02, 2007 11:55 pm

I may be missing something...
honestly I tried the chomp off at 7 and do a renumber with the renumber panel [9]

but here is what i got - because of the way they ( maybe ) were sorted in the windows

99922c1_1.jpg didn't become 99922c1_001.jpg
99922c1_2.jpg didn't become 99922c1_002.jpg

but rather the numbers were 'Off' and they stared incrementing
how they were stacked , I tried sorting by creation time.
But I suppose the creation time was so close that they did not stack
1-30 , so When I tried the (panel9) numbering it got all mixed up
example : something like 12 became 023 that sorta thing.

[ and I do really like the bulk renamer ]

make sense?
zimbot
 
Posts: 3
Joined: Mon Oct 01, 2007 6:16 pm

Postby bitmonger » Wed Oct 03, 2007 6:25 am

You could do it fairly simply in 2 passes.
We know there are some single and some double digits that need to be changed after the underscore.
In Selections(12) box put *.jpg to select only jpg files
In Regex(1) have Include Ext. NOT checked.
For the first pass, in Regex(1) box put

Search: ^(.+?_)(\d{2})$
Relace: \10\2

This says search for all files with exactly 2 digits after the underscore and capture in two groups split just after underscore; then replace with a zero between the two groups. Now we have all the double digit numbers with a zero prefix padding to make 3 digit numbers. e.g. 18 becomes 018.

Now do a second pass:

Search: ^(.+?_)(\d{1})$

Replace: \100\2

This searches out the single digit numbers and pads them with 2 zeroes.
e.g. 3 becomes 003

This works with all the sample files shown. If The first part of the filename has to be more specific, just change the first part of the regex
i.e. (.+?_) to something more specific - the .+? means any character one or more, in non-greedy fashion.

Hope this helps,
DM
bitmonger
 
Posts: 50
Joined: Sat Sep 22, 2007 5:05 am

yes that helps

Postby zimbot » Wed Oct 03, 2007 4:55 pm

yes thanks... that does help..
with this suggested method i can do the folder contents entire

My current solution ( with 2 passes ) was to do
([0-9]+c[0-9]+_)([0-9]+)

match pass 1
\10\2
selecting the 1-30 jpgs

then I did the same reg express again but bow i select only the 1-9
( 1 already has an 01 (etc) at that point )

I do appreciate your assistance . reg express ...
they are simple and yet HARD , i find it hard...

and now I am wondering if this can be done via command line?
hummmm
zimbot
 
Posts: 3
Joined: Mon Oct 01, 2007 6:16 pm

reg expression padding number seq

Postby Karapaz » Sun Jun 07, 2009 11:42 am

Hi:

How can I get control to any expression, in order to apply it in a layer or a group of layers, just in the time I decide, so I can switch on or off at taste, or maybe play with the expression parameters at different times.

Thanks
Karapaz
 
Posts: 6
Joined: Mon May 18, 2009 11:41 pm
Location: USA


Return to Regular Expressions