Tag math

Advanced Renamer forum
#1 : 31/10-21 19:06
Alan Reed
Alan Reed
Posts: 3
Can I add a number to a tag value

As in "<Video Date Hour>+1" so I could adjust values of the tags when composing filename?

Thanks if you can answer this :)

31/10-21 19:06
#2 : 02/11-21 11:20
David Lee
David Lee
Posts: 797
A simple solution is to insert the Hour tag as normal then add 1 using a Renumber method.

However you will run into problems if this takes you beyond midnight - which would lead to a value of 25.

You can use a Script method to get round this issue:
hour = parseInt(app.parseTags("<Video Date Hour>")) +1;
if (hour == 25) hour = 1;
hour = ("0" + hour).slice(-2);

However if you are inserting more than just the hour then you will also need to increment the day, possibly the month and maybe even the year!

A better scripting solution is to parse the date/time into a Unix epoch datestamp add 3600000 milliseconds then extract the hour using getUTCHours.

See my post in thread www.advancedrenamer.com/forum_thread?forum_id=11037 for an example of changing a timezone by +7 hours. You will need to extract the full timedate abd modify the regular expression appropriately and use the getUTC... versions of the date/time methods to avoid erroneous application of daylight saving.

02/11-21 11:20 - edited 02/11-21 12:22
#3 : 03/11-21 16:34
Alan Reed
Alan Reed
Posts: 3
Reply to #2:
The simple solution was all that was needed - thank you very much for your help.

I'm kicking myself I never though of that additional Method to tweak the hour value.

I sort of barely understand the more comprehensive solutions you offered but would ask if they were necessary but thanks nevertheless thanks for the insight as to how powerful AR can be.


03/11-21 16:34