Epoch script: add 5 hours to the time
Hi everybody. I'm using an epoch script (see below) I found on this forum and I know less than nothing about creating/editing the scripts.
Can someone tell me the change that is needed to add 5 hours to the time? Thanks for your assistance.
File name: 1746299268259420
converts to: 20250503_0914
should be: 20250503_1414 (file created 5/3/2025 2:14PM)
epoch = app.parseTags("<UnixTimestamp Modified>");
dat = new Date(1000 * epoch);
return dat.getFullYear().toString()
+ ("0" + (dat.getMonth() + 1)).slice(-2)
+ ("0" + dat.getDate()).slice(-2)
+ "_" + ("0" + dat.getHours()).slice(-2)
+ ("0" + dat.getMinutes()).slice(-2);
name = item.newBasename.match(/(.*_)(.*_)(.*_)(\d{10})(_.*)/);
dat = new Date(1000 * parseInt(name[4]));
return name[2]
+ dat.getFullYear()
+ "-" + ("0" + dat.getMonth()).slice(-2)
+ "-" + ("0" + dat.getDate()).slice(-2)
+ "_" + ("0" + dat.getHours()).slice(-2)
+ "-" + ("0" + dat.getMinutes()).slice(-2)
+ "-" + ("0" + dat.getSeconds()).slice(-2)
+ name[5];
Can someone tell me the change that is needed to add 5 hours to the time? Thanks for your assistance.
File name: 1746299268259420
converts to: 20250503_0914
should be: 20250503_1414 (file created 5/3/2025 2:14PM)
epoch = app.parseTags("<UnixTimestamp Modified>");
dat = new Date(1000 * epoch);
return dat.getFullYear().toString()
+ ("0" + (dat.getMonth() + 1)).slice(-2)
+ ("0" + dat.getDate()).slice(-2)
+ "_" + ("0" + dat.getHours()).slice(-2)
+ ("0" + dat.getMinutes()).slice(-2);
name = item.newBasename.match(/(.*_)(.*_)(.*_)(\d{10})(_.*)/);
dat = new Date(1000 * parseInt(name[4]));
return name[2]
+ dat.getFullYear()
+ "-" + ("0" + dat.getMonth()).slice(-2)
+ "-" + ("0" + dat.getDate()).slice(-2)
+ "_" + ("0" + dat.getHours()).slice(-2)
+ "-" + ("0" + dat.getMinutes()).slice(-2)
+ "-" + ("0" + dat.getSeconds()).slice(-2)
+ name[5];
Reply to #1:
Hi Ted,
Welcome back, and, by the way, congratulations on that whole Boston tunnel thing. Good work! :)
The simplest way, I think, is simply to use the adjustment parameter in the <UnixTimestamp Modified> tag. I can't swear to it, but 30 seconds of testing leads me to believe if you change the line:
epoch = app.parseTags("<UnixTimestamp Modified>");
to:
epoch = app.parseTags("<UnixTimestamp Modified:+5h>");
that may fix your hour problem (and save you a lot of sweat that Kim has already put in taking into account changing days and years in the adjustment).
This page: https://www.advancedrenamer.com/user_guide/v4/tags_datetimem odified at the bottom says all these date/time tags in the latest version of ARen are adjustable to take into account this kind of thing.
This page: https://www.advancedrenamer.com/user_guide/v4/tags_datetime# adjusting-output-value describes the adjustments that can be made.
Good luck!
Best,
DF
Hi Ted,
Welcome back, and, by the way, congratulations on that whole Boston tunnel thing. Good work! :)
The simplest way, I think, is simply to use the adjustment parameter in the <UnixTimestamp Modified> tag. I can't swear to it, but 30 seconds of testing leads me to believe if you change the line:
epoch = app.parseTags("<UnixTimestamp Modified>");
to:
epoch = app.parseTags("<UnixTimestamp Modified:+5h>");
that may fix your hour problem (and save you a lot of sweat that Kim has already put in taking into account changing days and years in the adjustment).
This page: https://www.advancedrenamer.com/user_guide/v4/tags_datetimem odified at the bottom says all these date/time tags in the latest version of ARen are adjustable to take into account this kind of thing.
This page: https://www.advancedrenamer.com/user_guide/v4/tags_datetime# adjusting-output-value describes the adjustments that can be made.
Good luck!
Best,
DF
Reply to #2:
Oh, if for some reason that doesn't give you the correct time you can probably do something like:
epoch = app.parseTags("<UnixTimestamp Modified>");
dat = ( new Date(1000 * epoch) + ( 5 * 3600) ) ;
I suspect (but can't guarantee) that will work.
Cheers!
EDIT: Tried it; didn't work... anyway, the first method seems to work.
BTW, did you mix two scripts together in your example? There are two returns with no qualifying "if" statement. I don't really understand, and it's been a while since I've had to deal with anything like that.
Oh, if for some reason that doesn't give you the correct time you can probably do something like:
epoch = app.parseTags("<UnixTimestamp Modified>");
dat = ( new Date(1000 * epoch) + ( 5 * 3600) ) ;
I suspect (but can't guarantee) that will work.
Cheers!
EDIT: Tried it; didn't work... anyway, the first method seems to work.
BTW, did you mix two scripts together in your example? There are two returns with no qualifying "if" statement. I don't really understand, and it's been a while since I've had to deal with anything like that.
Reply to #3:
Couldn't you also just use a NEW NAME method with:
<Date Modified:yyyymmdd_hhnnss:+5h>
?
Couldn't you also just use a NEW NAME method with:
<Date Modified:yyyymmdd_hhnnss:+5h>
?