Add number based on date

Advanced Renamer forum
#1 : 08/08-19 14:41
Michiel van Buuren
Michiel van Buuren
Posts: 1
I have a large number of images (~12.000) which are all named like this:


The ABC-9335489 is a subject identifier, so images with the same ABC-..... code are from the same subject.

After that is the date (yyyymmdd) the image was taken.

I want to rename the files so that the images per subject get V00, V01, V02 (for visit 0, visit 1, visit 2) added to them, according to the date. So earliest date is V00, after that V01 and most recent is V02.

Example of the wanted result would be:


Is this possible and if so: how can I do this? I tried finding it in the User Guide, and tried understanding the Regular Expressions, but I did not find a way.

I read that I can use a name collision rule to add numbers if I just remove the date and leave the subject identifier, but how would I know that the correct numbers are given to the correct date? Or is it random that way? Also the images are not all in 1 folder, but there are subfolders for each subject and within those folders there are subfolders for each date.

Thanks in advance!

08/08-19 14:41 - edited 08/08-19 14:42
#2 : 10/08-19 11:12
David Lee
David Lee
Posts: 473
Import all your filenames into the list and arrange in increasing alphabetical order (click on the "Filename" column header if necessary).

Then use the Script method with the following code...

Click the "Pre batch script..." button and enter:

var lastID = "";
var visitNo = 0;

Then in the main script window enter:

var str =;
match = str.match(/(.*-)(.*)/);
ID = match[1];
date = match[2];
if (ID != lastID) {
visitNo = 0;
visit = "V" + ("0" + visitNo).slice(-2);
visitNo += 1;
newName = ID + visit + "-" + date;
lastID = ID;
return newName;

This will handle up to 10 visits for each subject identifier, since ("0" + visitNo).slice(-2) returns the final two digits of the visit number, padded with a leading zero where necessary.

10/08-19 11:12
#3 : 01/09-19 14:25
Posts: 61
Reply to #1:

Assuming you are using windows os, I think you can do this in Excel (load the file names, separate them into cells using Text Import Wizard and delimiter = "-", then sort them by second row, then use a concatenate function to build a renaming command using your criteria, and execute it in windows command prompt.

01/09-19 14:25