Incrementing numbers based on time interval (Base 60)

Advanced Renamer forum
#1 : 05/05-24 17:51
John
John
Posts: 2
I want to apologize in advance...I hope I am explaining clearly what I'm looking for.

I'd like to add incrementing numbers to a filename based on a time interval (60 seconds), where it rolls over to a new minute after reaching 60 seconds, then the next hour, etc.

I have about 1200 photos that covered a 2-hour event on the same day. That makes 7200 seconds for 1200 photos. Each photo would have a 6 second time interval. Before you ask, the photos don't have any accurate EXIF time data, it was all cleared out or made inaccurate before I got to the photos. So I am creating a time estimate in the filename of the photos based off when the event took place that day.

The format I use for photos is YYYYMMDD_HHMMSS

Ex:

20240421_000001
20240421_000002
20240421_000003
20240421_000004
20240421_000005
20240421_000006
20240421_000007
20240421_000008
20240421_000009
20240421_000010
20240421_000011
20240421_000012
all the way to
20240421_001200

I want to rename them to
20240421_130001
20240421_130007
20240421_130013
20240421_130019
20240421_130025
20240421_130031
20240421_130037
20240421_130043
20240421_130049
20240421_130055
20240421_130101
20240421_130107
all the way to
20240421_150000


Again, apologies if I'm not explaining very well. Thank you in advance.


05/05-24 17:51
#2 : 06/05-24 00:25
Delta Foxtrot
Delta Foxtrot
Posts: 124
Reply to #1:

Hi John,

A simple renumber will do what you want. First, make sure your files are all in the file list and in ascending filename order, otherwise you'll get error messages. (You do have backups, right? Not that anything will go wrong, what with preview undo, but hey, its' easier to copy files to a temp directory than suffer that heart attack when you realize you screwed the pooch :)

Renumber method:

Number position: 2
Change to: Absolute number
New number: 1
Skip: 6
Zero padding: Manual
Number length: 6
Apply to: Name

That should do it for you. The only weird part, at least to my dog brain, is the "number position" field. For some reason it took me some thinking and head-scratching to realize that that's not the actual position of the number to change, it's the "number group." The underscore in your filenames is what breaks up the number into two groups. Anyway, once you "get" that it's all cruisin'.

I advise a good session with the user guide. It's amazing what you can learn. :)

Best, DF


06/05-24 00:25
#3 : 06/05-24 10:23
Miguel
Miguel
Posts: 65
Reply to #2:
The New Name method, also, will do the trik:
New Name: 202040421_<Inc Nr:130001:6>
Mmmm
But do you know what? None of our solutions are usefull for John, because this renumber is not what he want.
What he want is renumber chronometer style.
20240421_130001
20240421_130007
20240421_130013
20240421_130019
20240421_130025
20240421_130031
20240421_130037
20240421_130043
20240421_130049
20240421_130055
He want restart the renumber and add a minute:
20240421_130101
20240421_130107
I have no idea how this can be done with ARen. I think can´t be do. Even regex can´t.
I think that the only possible solution would be a script and here the only one that can help you with that is Delta Foxtrot. Me, for sure, NOT



06/05-24 10:23
#4 : 06/05-24 21:17
Miguel
Miguel
Posts: 65
Hi again.
I made the incremental interval in Excel. Was easy. Then I pasted the result in a text file.
Load all the files 20240421_000001...20240421_001200 in Advanced Renamer and I made the next.
Method 1
List: Load the list (List.txt)
Method 2
Add: 20240421_
Position: 0

This is the result:
https://i.ibb.co/TwWCSfb/Captura-06-05-2024-20s. png

If yo want can download the list.txt file from this link:
https://drive.google.com/file/d/1XchSiXE0WP8qk4P QwG7oUn1t5NWVy-3R/view?usp=drive_link
I hope don´t have any problem.

Miguel



06/05-24 21:17
#5 : 06/05-24 23:03
Delta Foxtrot
Delta Foxtrot
Posts: 124
Reply to #4:

Bravo Miguel! Brilliant!

I totally missed the minutes/hours thing when I read that post. Just saw it while making coffee and was thinking about how to attack it. My first thought was to go to a spreadsheet as well. What formula did you use, if I might ask?

Just so you know, I hate math, and the thought of something like this gives me the stuttering shakes. :) (Half-kidding)


06/05-24 23:03
#6 : 07/05-24 06:46
Delta Foxtrot
Delta Foxtrot
Posts: 124
Reply to #5:

Hola Miguel,

You inspired me. Once I got my brain to stop turning in circles and nipping at its tail it wasn't too bad. :)

And John, sorry for the earlier misstep. But you've probably already got your files done from Miguel's work, so perfect! Anyway, I tried to generalize this script a bit so if you run into a similar problem again you might be able to just jimmy this one a little bit to fit.

// -----------------------------------------------------------
// PRE-BATCH:
const splitChr = "_";
const timeStr = "";
const timeNr = 0;
const minute = 0;
const hour = 13;
const secondStr = "00"
const minuteStr = "00"
const hourStr = "13";
const totNrStr = "130001";
// Array that holds the values for seconds. Easier and probably faster
// than computing them:
const replArr = [ "55", "01", "07", "13", "19", "25", "31", "37", "43", "49" ];
const prefixStr = "";

// SCRIPT:
// Extract two parts of the filename:
nameArr = item.newBasename.split( splitChr );
// First part into var prefixStr for return later:
prefixStr = nameArr[0].toString();
// The index we use to check our pre-batch array:
timeNr = ( timeNr == 9 ) ? 0 : timeNr + 1;

// Special case first file in the series. Only executes once:
if ( app.currentIndex == 0 ){
// create return string one time:
var returnStr = prefixStr + splitChr + totNrStr;
// One down!
return returnStr;
}
// If we are here it's not the first iteration.
// Get the array element for seconds:
secondStr = replArr[timeNr];
// First filename in this minute?
if (secondStr == "01"){
// If so check that we are not in a new hour.
// It's a boring job but somebody has to do it.
// Increment minute number and make it a string
minute = minute + 1;
minuteStr = minute.toString();
// Check if we hit the hour boundary:
if (minute > 59){
// if so increment hour counter, zero out minute counter and marker:
hour = hour + 1;
minute = 0;
minuteStr = "00";
}
}
// Now it's just a matter of formulating the return string:
hourStr = hour.toString();
if ( hourStr.length == 1 ) {
// Pad it. Wish I had "padStart(), but this is simple enough.
hourStr = "0" + hourStr;
}
if (minuteStr.length == 1 ) {
// Pad again.
minuteStr = "0" + minuteStr;
} // Build the return string:
returnTimeStr = hourStr + minuteStr + secondStr;
// Time for a glass of cabernet! :)
return prefixStr + splitChr + returnTimeStr;

// -----------------------------------------------------------

I figured out the formulas to do it all in math, but realized it was probably faster just to pick values from an array based on file numbers using incrementing/decrementing counters. It was certainly easier on my dog-brain!

Fun stuff, huh? I guess that's why we lurk here! LOL

Best,
DF


07/05-24 06:46 - edited 07/05-24 06:51
#7 : 07/05-24 13:59
Miguel
Miguel
Posts: 65
Reply to #6:
I knew you could do it. As for my solution, I didn't use any formula, I just used the autofill option.
I insert in a cell the number in time format.
13:00:01
13:00:07
Select both cells and drag the row to 1200.
then you must delete the ":" in the text editor because you can´t have the : in files names.
Tha´s was all.

Miguel




07/05-24 13:59
#8 : 07/05-24 22:32
Delta Foxtrot
Delta Foxtrot
Posts: 124
Reply to #7:

Awesome! And that's why YOU DA MAN!

I didn't even think of that. I had like six columns of hour/minute/second representations, trying to pinpoint methods to create the roll-overs. I wasn't able to do it on the spreadsheet but it did clarify the problem for me.

Good work brother!

DF



07/05-24 22:32