Add numeric sequence?

A swapping-ground for Regular Expression syntax

Add numeric sequence?

Postby msond » Mon Nov 25, 2013 2:27 pm

I have a bunch of files that follow a certain naming convention, but the last digit changes with each file to the next available number.
They need re-named to another naming convention, again with the last digit becoming the next available number.
Example:
01_SP_01_00_00.pdf|G001.pdf
01_SP_01_00_01.pdf|G002.pdf
01_SP_01_00_02.pdf|G003.pdf
etc, etc. for G004, G005.
How do I phrase this so that I don't need a new line for each file? (if I have 100 files)

Please help? I"m lost.
msond
 
Posts: 2
Joined: Mon Nov 25, 2013 2:21 pm

Re: Add numeric sequence?

Postby Stefan » Mon Nov 25, 2013 8:10 pm

msond wrote:I have a bunch of files that follow a certain naming convention, but the last digit changes with each file to the next available number.
They need re-named to another naming convention, again with the last digit becoming the next available number.
Example:
01_SP_01_00_00.pdf|G001.pdf
01_SP_01_00_01.pdf|G002.pdf
01_SP_01_00_02.pdf|G003.pdf
etc, etc. for G004, G005.
How do I phrase this so that I don't need a new line for each file? (if I have 100 files)

Please help? I"m lost.



Your example looks like this would work:

- remove file name
- add "G"
- add numbering
Rename





Please wait a few seconds then submit. Thank you.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Add numeric sequence?

Postby msond » Mon Nov 25, 2013 10:06 pm

Thanks Stefan.
That gets me on the right path, it now changes ALL names to the G001, G002 etc. naming convention.

What if i want to change multiple naming conventions in a single batch? Is that possible?
ex:
01_SP_01_00_00.pdf|G001.pdf
01_SP_01_00_01.pdf|G002.pdf
01_SP_01_00_02.pdf|G003.pdf
03_A_01_00_00.pdf|A001.pdf
03_A_01_01_00.pdf|A002.pdf
03_A_01_02_00.pdf|A003.pdf
04_S_02_00_00.pdf|S001.pdf
04_S_03_00_00.pdf|S002.pdf
04_S_04_00_00.pdf|S003.pdf

i.e. IF it starts with 01*, then change it to G001, etc.
IF it starts with 03, then change it to A001, etc.
IF it starts with 04, then change it to S001, etc.
Is it possible to rename those files to the G, A, or S suffix in a single command, or would I have to run 3 different times for this to happen?

Thanks for the help, I am an extreme newb at this.
msond
 
Posts: 2
Joined: Mon Nov 25, 2013 2:21 pm

Regex-match, then CharTranslate, then Number

Postby truth » Tue Nov 26, 2013 3:36 am

You can regex-match the 1st two #'s, & then let CharTranslation convert them:

12Filter=*_*_*_*_*
Make sure you only see filenames with 4 underscores

1Regex
^(\d\d)_[A-Z]*_\d\d_\d\d.*$
\1
Capture only the 1st 2-digits of filenames in your format (before CharTranslation gets hold of them)

CharTranslation
0,1=G
0,3=A
0,4=S
9,9=W,h,a,t,e,v,e,r
Etc, I'd prob create this in a txt-file, & then paste into Options/CharTranslations
See www.bulkrenameutility.co.uk/forum/viewtopic.php?f=4&t=1329 for more info

10Numbering
Mode=Suffix
Start=1
Incr=1
Pad=3
Break=1

That renames as described, just dont forget to put * back in 12Filter when you're done!
Another option might be matching the text between 1st/2nd underscore, depending on filenames.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to Regular Expressions


cron