Increment with fixed length

Advanced Renamer forum
#1 : 02/06-24 09:09
Marc
Posts: 3
I use IncHex (but I suspect this goes for other increment options as well) to give unique names to photos. The basic part is date and time, but since I often shoot several photos per second only time wasnt enough. So I add IncHex.

My problem is that I want all my filenames to have the same length. However, if I have less than 16, IncHex will insert 1 character and if I have over 256 it will insert 3. I want it to be always 2, and have the sequence start over again when it reaches FF. So apart from x (starting number) and y (step) I would also like to see a z (length).

edited: 02/06-24 10:02
#2 : 02/06-24 11:58
Delta Foxtrot
Posts: 323
Reply to #1:

Hi Marc,

I've never used IncHex, but according to the user guide it obeys the same rules as IncNr, which means if you insert <Inc Hex:001> it should pad all increments with zeros to the same length. Have you tried that?

Best,
DF

edited: 02/06-24 11:59
#3 : 03/06-24 08:25
Marc
Posts: 3
Reply to #2:

Thanks for the reply. That does work for less than 16 files (or 10 if you us numeric), but not for more than 256/100. Then it will add a character and not start over.
The way I envision it, if a "z" argument is added to Inc, the above behavior should be default if z is not given; if it is, the Inc will always have the length of z and start over.
#4 : 03/06-24 10:46
Delta Foxtrot
Posts: 323
Reply to #3:

I guess I don't understand what you are trying to do. I added 699 files and then added <Inc Hex:001> as an ADD method, and all 699 files added a 3-digit hex number. So good luck, maybe someone else can help you.

Best,
DF
#5 : 04/06-24 03:47
Delta Foxtrot
Posts: 323
Reply to #4:

Is this what you are looking for?

https://drive.google.com/file/d/1_0mzvglwLPCKT8X uhhRnx4keJj7x1mez/view?usp=sharing



SCRIPT METHOD:

(Pre script)

const currentCounter = 0;


(Script)


if ( currentCounter >= 15 ){
currentCounter = 0;
}
currentCounter++;
rStr = currentCounter.toString(16);
if (rStr.length == 1) {
rStr = "0" + rStr ;
}
return item.newBasename + "_" + rStr.toUpperCase();

EDIT:
OOPS! I forgot you only wanted two digits. I've fixed it in the script, although it doesn't show in the screenshot I attached.
If you don't want the underscore, just remove <+ "_" > (without angle brackets) from the "return" line of the script.
END EDIT


edited: 04/06-24 04:03
#6 : 11/07-24 11:04
Marc
Posts: 3
Reply to #5:

I did't see your last reply, sorry (and thanks for the effort!). But I've since found a nice solution without coding. My first rule adds <Inc Hex:000>, so 3 characters. This allows me to generate 4096 unique names before the increment adds a fourth character, which is more than enough in my case. Now, I've added a second rule that Removes the first of those 3. So now it will generate:
0FD
0FE
0FF
100
101
in the first rule, and the second rule will instantly convert it to:
FD
FE
FF
00
01
This is what I wanted to give unique filenames for those situations where I've shot more than 10 frames within the same second :-)

edited: 11/07-24 11:23