Time Zone

Advanced Renamer forum
#1 : 20/01-18 02:02
Richard Tan
Richard Tan
Posts: 1
Hi (^.^)

May I know how to change filename (YYYYMMDD_HHMMSS) as below:

original file: 20180101_080554.jpg
to file as: 20180101_070554.jpg
(1 hour behind)

Thank you and your help is much appreciated


20/01-18 02:02
#2 : 02/02-18 02:46
Brian Hanlon
Brian Hanlon
Posts: 29
Reply to #1:
To avoid confusion and aid in solving this - is the MM (month) section 01-12 (Human) or 00-11 (Brain-dead JS)?

Brian.

----------
If this brilliant little tool has saved you time, or helped get your files in a better order, or just cleaned-up the crazy names from downloaded files, maybe you could donate a Dollar or Ten to Kim?
See https://www.advancedrenamer.com/download


02/02-18 02:46
#3 : 02/02-18 06:30
Brian Hanlon
Brian Hanlon
Posts: 29
Reply to #1:
I've assumed that the YYYMMMDD is 'Human' style, and produced this script for you:

1. Start AR
2. Clear ALL Methods
3. Select a test set of files
4. With NO OTHER METHODS in place, select 'Script" from right down the bottom, beside 'Attributes' and 'Timestamp'
5. In the 'Script' Method box, click 'Show in window'
6. Ctrl-a to select all numbered lines, 'Del' to clear them
7. Copy everything BETWEEN the two '=====' lines below
8. Ctrl-V Paste into the Script edit box in AR
9. Click 'Close and apply script'
10. Observe the proposed changes (if you have 'Auto Test' ON, else hit 'Test Batch')
11. If satisfied with the results, Save the Method List - that's the funny icon last in the row above the 'Presets' Selector. Once saved, you can reload it for another run, even after changing all the Rules for a totally different job. You'll gradually build up a library of 'Presets' which will come in handy next time you get a similar task to perform.
========================================
var str = item.name;
var deltaHrs = -1;
var deltaMs = deltaHrs * 60 * 60 * 1000 /* Hrs to min to sec to ms */
var fixmnth = -1;
var Sccyy = str.substr(0,4);
var Smm = str.substr(4,2);
var Sdd = str.substr(6,2);
var Shh = str.substr(9,2);
var Snn = str.substr(11,2);
var Sss = str.substr(13,2);

var inStamp = new Date(Date.UTC(Sccyy,Smm,Sdd,Shh,Snn,Sss,0));
inStamp.setMonth(inStamp.getMonth() + fixmnth); /* Curse JS 0-11 Months */

var isoNew = new Date(inStamp.getTime() + (deltaMs)).toISOString();

var Fccyy = isoNew.substr(0,4);
var Fmm = isoNew.substr(5,2);
var Fdd = isoNew.substr(8,2);
var Fhh = isoNew.substr(11,2);
var Fnn = isoNew.substr(14,2);
var Fss = isoNew.substr(17,2);

var newName = Fccyy + Fmm + Fdd + "_" + Fhh + Fnn + Fss;

return newName;
========================================

TESTING BEFORE:

C:\TESTING>DIR /B

20180101_005959.jpg
20180101_005959.png
20180101_005959.txt

20180101_080554.jpg
20180101_080554.png
20180101_080554.txt

RESULTS AFTER:

C:\TESTING>DIR /B

20171231_235959.jpg
20171231_235959.png
20171231_235959.txt

20180101_070554.jpg
20180101_070554.png
20180101_070554.txt

(Spacing added for clarity.) - Your original Name data has altered exactly as required, and a test to roll back to a previous month and year has shown correct handling of that circumstance.

Hope that helps get you going, and gets you intrigued by just what can be done with AR

Brian.

----------
If this brilliant little tool has saved you time, or helped get your files in a better order, or just cleaned-up the crazy names from downloaded files, maybe you could donate a Dollar or Ten to Kim?
See https://www.advancedrenamer.com/download


02/02-18 06:30