help about changing day and hour of thousand of files

Advanced Renamer forum
#1 : 10/11-22 20:45
Tucoco
Tucoco
Posts: 3
I have found out in thousands of files i had from downloads from like 1-2 years ago something. The app i used in the past no longer works and now im using other but it download it with a 3 hour difference compared to my old database.

What i need is a way to batch change the hour difference in filenames and in some cases even the day of all my old database.

For example i need to change from this 2021-02-11 11.24.09 -> 2021-02-11 14.24.09
In cases it changes day it need to take that in account automatically:
2020-05-09 21.45.21 -> 2020-05-10 00.45.21

What kind of commands need to add the ARen?


10/11-22 20:45
#2 : 11/11-22 20:34
David Lee
David Lee
Posts: 1026
Use a Script method.

Extract Y, M, D, h, m & s using a regular expression match.
Add 3 to h
Create a new Date
Extract Y, M, D, h, m & s from the new date
Format and return.

This script should do it:

deltaHour = 3;
match = item.name.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2})\.(\d{2})\.(\d{2})/);
log(match);
if (match) {
Y = 1*match[1];
M = 1*match[2] - 1;
D = 1*match[3];
h = 1*match[4];
m = 1*match[5];
s = 1*match[6];
h += deltaHour;
date = new Date(Y, M, D, h, m, s);
Y = date.getFullYear();
M = date.getMonth() + 1;
D = date.getDate();
h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
return Y + "-" + ("0" + M).slice(-2)+ "-" + ("0" + D).slice(-2)
+ " " + ("0" + h).slice(-2) + "." + ("0" + m).slice(-2) + "." + ("0" + s).slice(-2);
}


11/11-22 20:34 - edited 12/11-22 10:38
#3 : 13/11-22 07:30
Tucoco
Tucoco
Posts: 3
Reply to #2:
Wow that is amazing, thanks.
Just one question how can i make it respect the rest of the filename without deleting it?
2020-05-09 21.45.21 xxxxxxxxxxxxx.jpg -> 2020-05-10 00.45.21 xxxxxxxxxxxxx.jpg


13/11-22 07:30
#4 : 13/11-22 11:19
David Lee
David Lee
Posts: 1026
Reply to #3:

deltaHour = 3;
match = item.name.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2})\.(\d{2})\.(\d{2})(.*)/);
if (match) {
Y = 1*match[1];
M = 1*match[2] - 1;
D = 1*match[3];
h = 1*match[4];
m = 1*match[5];
s = 1*match[6];
h += deltaHour;
date = new Date(Y, M, D, h, m, s);
Y = date.getFullYear();
M = date.getMonth() + 1;
D = date.getDate();
h = date.getHours();
m = date.getMinutes();
s = date.getSeconds();
return Y + "-" + ("0" + M).slice(-2)+ "-" + ("0" + D).slice(-2)
+ " " + ("0" + h).slice(-2) + "." + ("0" + m).slice(-2) + "." + ("0" + s).slice(-2)
+ match[7];
}


13/11-22 11:19
#5 : 13/11-22 17:37
Tucoco
Tucoco
Posts: 3
Reply to #4:

You are very smart, thank you very much.


13/11-22 17:37