Picture numbering starting at 0 for each day

Advanced Renamer forum
#1 : 14/02-21 11:32
Marco
Marco
Posts: 3
I often renumber huge batches of pictures (e.g. from my smartphone, the pictures of a whole year), until now with another batch renamer (but it has some issues so I'm looking for a new one, and advanced renamer looks promising).

I would like the numbering starting from zero for each day.
For the other renamer I wrote a script to do that (it is a little bit complicated).
Can advanced renamer do this by it's own or do i also need to write a script?

Here a example what I mean:
original name new name expected name creation date
20210105_145021.jpg DCIM 2021.01.05_0000.jpg DCIM 2021.01.05_0000.jpg 05.01.2021 14:50
20210106_131252.jpg DCIM 2021.01.06_0001.jpg DCIM 2021.01.06_0000.jpg 06.01.2021 13:12
20210106_131315.jpg DCIM 2021.01.06_0002.jpg DCIM 2021.01.06_0001.jpg 06.01.2021 13:13
20210106_161451.jpg DCIM 2021.01.06_0003.jpg DCIM 2021.01.06_0002.jpg 06.01.2021 16:14
20210107_111101.jpg DCIM 2021.01.07_0004.jpg DCIM 2021.01.07_0000.jpg 07.01.2021 11:11
20210107_112645.jpg DCIM 2021.01.07_0005.jpg DCIM 2021.01.07_0001.jpg 07.01.2021 11:26
20210107_112819.jpg DCIM 2021.01.07_0006.jpg DCIM 2021.01.07_0002.jpg 07.01.2021 11:28
20210109_204552.jpg DCIM 2021.01.09_0007.jpg DCIM 2021.01.09_0000.jpg 09.01.2021 20:45
20210111_165645.jpg DCIM 2021.01.11_0008.jpg DCIM 2021.01.11_0000.jpg 11.01.2021 16:56
20210117_190322.jpg DCIM 2021.01.17_0011.jpg DCIM 2021.01.17_0000.jpg 17.01.2021 19:03
20210117_190912.jpg DCIM 2021.01.17_0012.jpg DCIM 2021.01.17_0001.jpg 17.01.2021 19:09


Here my script from the other renamer (it's Pascal), can someone help to translate in Java?
var
counter:Integer;
FileDate: TDateTime;
countdate:String;


begin

FileDate := FileTimeModified(FilePath);

if countdate<>DateToStr(FileDate) then counter:=0;

if counter>=1000 then
FileName := 'MOV ' + FormatDateTime(' yyyy.mm.dd', FileDate) + '_' + '' + IntToStr(counter) + WideLowerCase(WideExtractFileExt(FileName));

if (counter<1000) AND (counter>=100) then
FileName := 'MOV ' + FormatDateTime(' yyyy.mm.dd', FileDate) + '_' + '0' + IntToStr(counter) + WideLowerCase(WideExtractFileExt(FileName));

if (counter<100) AND (counter>=10) then
FileName := 'MOV ' + FormatDateTime(' yyyy.mm.dd', FileDate) + '_' + '00' + IntToStr(counter) + WideLowerCase(WideExtractFileExt(FileName));

if counter<10 then
FileName := 'MOV ' + FormatDateTime(' yyyy.mm.dd', FileDate) + '_' + '000' + IntToStr(counter) + WideLowerCase(WideExtractFileExt(FileName));

countdate:=DateToStr(FileDate);
counter:= counter + 1;

end.


14/02-21 11:32
#2 : 14/02-21 15:41
David Lee
David Lee
Posts: 1125
You will need to use a script.

I don't understand why you include "new name" and "creation date" columns in your table - I'm assuming here that "expected name" is the result that you are aiming for. I haven't included any error checking - just assuming that all filenames in the List are in the correct format (ie the first 8 characters in each filename are in the format yyyymmdd).

First make sure that your filenames are sorted in ascending order in the List.

Define a variable to keep track of the date from the previous filename and set it to null in the Pre-batch script:

lastDate = "";

Then in the Main script:

date = item.name.slice(0,8);
if (date == lastDate) {
no++;
} else {
lastDate = date;
no = 0;
}
return "DCIM " + date.slice(0,4) + "." + date.slice(4,6) + "." + date.slice(6,8) + "_"
+ ("000" + no).slice(-4);


14/02-21 15:41 - edited 14/02-21 15:57