numbering a batch of files

Advanced Renamer forum
#1 : 04/05-20 01:11
Denise Evans
Posts: 1
in ascending order.

I love your program, should have known someone would come up with this great tool ;) I am trying it out and have files numbered 19 through 24 but will all sorts of junk I don't need in the name. I add the files, put in the name (but just the first which would be 19). After that I click on Add Method but I can't get the filename to be anything but 19 for all files. I just want them to be 19, 20, 21, 22, 23, and 24.

Could someone show me how to do this? I found a couple of posts on renaming files, with perfect answers for the 2 people that knew/understood the code. So I need someone to put it in simpler terms for me til I get the hang of the program. Thanks in advance for anyone that might be able to help me.
#2 : 04/05-20 10:21
David Lee
Posts: 1125
You question doesn't make much sense so I'll have to try to guess what you are trying to do!

I assume that each filename contains one of these two-digit numbers buried in other characters and you wish to rename the files with just the two-digit numbers.

You will need to use the Replace method with a Regular Expression - the section in the User Guide should give you enough information to solve the problem: https://www.advancedrenamer.com/user_guide/regul ar_expresions

However - to get you started...

First to extract ANY 2-digit number use the pattern: .*(\d{2}).*

Each ".*" will match a string of characters of any length (including zero).
"(\d{2})" will match a string of two digits and enclosing in parentheses means that the match will be saved in the variable \1 - so the Replace string will be \1

However the "*" modifier is "greedy" and the first ".*" will match as many characters as possible before moving on to select the two digits. So if you have more than two pairs of digits, or a string of more than two digits, this will return the latest possible match.

eg abc223def will return 23

Adding "?" after the "*" will reverse this behaviour and make the modifier "lazy" so it will match the minimum number of characters and the match will return the first pair of digits

so .*?(\d{2}).* will return 22 in the above example.

If you need to match ONLY the two digit numbers from 19 to 24 you can use the OR character - "|" - in the regular expression.

eg the regular expression .*?(19|20|21|22|23|24).* will return the first instance of any one of these numbers, in the variable \1

I hope this explanation is sufficiently clear.


edited: 04/05-20 15:52