Can I adjust "Append incrementing number" collision rule?

Advanced Renamer forum
#1 : 05/03-19 02:59
Lonnie
Lonnie
Posts: 2
Hi guys,
I need a way to adjust the numbering routine that is produced by the "Append incrementing number" collision rule. This rule is fantastic and does exactly what I need - EXCEPT - that my software (that uses the renamed images) requires the numbering to be 2 digits, not 3 digits.

Here is what the "Append incrementing number" rule does now:
Foo.txt
Foo_001.txt
Bar.txt
Bar_001.txt
Bar_002.txt

But I need it to result like this:
Foo.txt
Foo_01.txt
Bar.txt
Bar_01.txt
Bar_02.txt

Thoughts or comments on how to accomplish this? TIA.


05/03-19 02:59
#2 : 05/03-19 09:04
David Lee
David Lee
Posts: 1125
You can't specify the length of zero-padding in the collision rule so you will have to edit the new filenames and, since the collision rule is applied after all methods have completed, you will need to do this in a second pass.

If the filenames do not contain any other numbers you can use the Renumber method:
... Change to: Relative to existing number
... Number difference: 0
... Zero padding: Manual
... Number length: 2

Otherwise use the Replace method with a Regular Expression to modify the number at the end of the filename.
One possibility is:
... Text to be replaced: (\d)(\d{2}$)
... Replace with: \2


05/03-19 09:04
#3 : 05/03-19 14:37
Lonnie
Lonnie
Posts: 2
Reply to #2:
Thanks David Lee!

I think we made some progress here, but while it fixed the 2 digit issue, it also removed digits from the main file name, which is problematic.

My original photos (after the first AR run) look like this:

001012.jpg
001013_001.jpg
001013_002.jpg
400110.jpg
400150_001.jpg
400150_002.jpg
400150_003.jpg

Setting aside the fact that the software I used is too "dumb" to handle the 001 and 002 and 003 at the end of the filenames, I need those to be 01 and 02 and 03.
Your method with the regular expression worked :) but it also removed one of the digits from the main part of the filename.

Any other suggestions?


05/03-19 14:37
#4 : 05/03-19 16:29
David Lee
David Lee
Posts: 1125
Reply to #3:
Sorry - stupid omission, I overlooked the case where the filename ended with three valid digits.

Easy to fix - use Replace with a RegEx:

... Replace: _\d(\d{2}$)
... with: _\1

Searches for an underscore followed by 3 digits at the end of the string and saves the last two digits as sub-pattern "\1"

Replacement is an underscore followed by the 2 digits saved in \1

There can only be one occurrence (since $ defines the end of the filename) so you must select either 1st or All occurrences.

Edit: A better solution would be to use _0(\d{2}$) as the search string, which would only remove a leading zero and so protect genuine 3-digit collision extensions - but I don't think such a situation can occur in your case.


05/03-19 16:29 - edited 07/03-19 00:32