How to Renumber?

Advanced Renamer forum
#1 : 24/09-20 00:13
SAM
SAM
Posts: 9
Hello.

File name:

INV_20200924_IVA01_$100.00_CUSTOMER Z
INV_20200924_IVA01=IVB01_$100.00_CUSTOMER Z
INV_20200925_IVA02_$102.00_CUSTOMER Y
INV_20200925_IVA02=IVB02_$102.00_CUSTOMER Y
NV_20200926_IVA02_$104.00_CUSTOMER X
INV_20200926_IVA02=IVB03_$104.00_CUSTOMER X
NV_20200927_IVA02_$106.00_CUSTOMER W
INV_20200927_IVA02=IVB04_$106.00_CUSTOMER W

How to rename as follow?

INV_20200924_01_IVA01_$100.00_CUSTOMER Z
INV_20200924_01_IVA01=IVB01_$100.00_CUSTOMER Z
INV_20200925_02_IVA02_$102.00_CUSTOMER Y
INV_20200925_02_IVA02=IVB02_$102.00_CUSTOMER Y
INV_20200926_03_IVA02_$104.00_CUSTOMER X
INV_20200926_03_IVA02=IVB03_$104.00_CUSTOMER X
NV_20200927_04_IVA02_$106.00_CUSTOMER W
INV_20200927_04_IVA02=IVB04_$106.00_CUSTOMER W

Thanks.


24/09-20 00:13
#2 : 24/09-20 11:05
David Lee
David Lee
Posts: 542
You need to use a script for this one.

First, enter this code in the Pre batch script:
var suffix = 1;
var lastID = app.getItem(1).name.match(/_\d*_/)[0];

Then, in the main script window:
match = item.name.match(/(.*)(_\d*_)(.*)/);
ID = match[2];
if (ID != lastID) {
lastID = ID;
suffix += 1;
}
return match[1] + ID + ("00" + suffix).slice(-2) + "_" + match[3];

Read the User Guide sections on Scripting and Regular Expressions.
For more advanced information search the Internet.
I find resources at www.w3schools.com and www.regular-expressions.info particularly helpful


24/09-20 11:05