restart numbering IF

Advanced Renamer forum
#1 : 01/08-19 02:06
kwapster
kwapster
Posts: 5
I have files in the following format:

ITT400-blah blah
MTH200-blah blah
BSC530-blah blah

Is there anyway to restart numbering when the first 6 characters change? eg

ITT400-01
MTH200-02
BSC530-03

to

ITT400-01
ITT400-02
MTH200-01
BSC530-01


01/08-19 02:06 - edited 01/08-19 04:12
#2 : 01/08-19 10:25
David Lee
David Lee
Posts: 1125
You will get part way there if you use the New name method - rename to <Substr:1:6> and set the collision rule to "Append number" with separator = "-".

However appended numbers will be padded to 3 digits and only applied where there is a collision.

You can get around this using two passes...

1) New name method -> <Substr:1:6>-01 with collision rule as above.

Run the batch, reloading all files - then:

2) Replace method, using Regular expressions...
Replace: 01-0(\d\d)$
With: \1


01/08-19 10:25
#3 : 01/08-19 17:05
David Lee
David Lee
Posts: 1125
Reply to #2:

... or you could use a "lookahead" in step 2 and use the Remove method
with Regular expression Pattern = 01-0(?=\d\d$)


01/08-19 17:05