app.parseTags does not work properly

Version 4.16

Hello everyone,

for me it looks like the app.parseTags function does not work properly.

Refering to this forum entry:
https://www.advancedrenamer.com/forum_thread/item-createddat e-not-working-anymore-15375

it should be possible to use:
myArray = app.parseTags( "<ExifTool:FileCreateDate:yyyy-mm-dd-hh-m-ss>" ).split("-") ;
to get a formated String yyyy-mm-dd-hh-mm-ss.

But i still get the format 2020-12-31 23-06-40.
I tought i use the formating chars wrong so i also tested:
yyyy-mm-dd-hh-mm-ss
yyyy-mm-dd-hh-nn-ss

But i got the same result.

console.log(app.parseTags("<ExifTool:DateTimeOriginal:yyyy-mm-dd-hh-nn-ss>"));
console.log(app.parseTags("<ExifTool:CreateDate:yyyy-mm-dd-hh-nn-ss>"));
console.log(app.parseTags("<ExifTool:ModifyDate:yyyy-mm-dd-hh-nn-ss>"));

Nethertheless i updated my parser.
But i want to know where i messed up :)

So thanks for helping:)
Reply to #1:

Hi Giona,

Kim will have to verify this, I can't speak for him, but I think it just got too much to do formatting on the externally-generated ExifTool values. Since v4, Kim has been adding and polishing the internally-generated tags so that they are very accurate and mirror values from ExifTool. And they have a wealth of ways to modify and fall back to other values or default strings if necessary.

Try using one of the tags that are built in to ARen, instead of ExifTool values. They correspond closely, but the formatting commands work there:

EDIT: Sorry, I messed up the following command initially; fixed now. END EDIT
myArray = app.parseTags( "<DateTimeOriginal:yyyy-mm-dd-hh-nn-ss:>" ).split("-") ;

yields something like
[
"2018",
"05",
"24",
"14",
"57",
"19"
]
...and you can use all the other nifty formatting modifiers and fallbacks, for instance time adjustment.

Hope this helps!
Best,
DF
Reply to #1:

Hello!

Yeah I can't get the format to work either -- not that I tried hard yet.

DF is right -- except that it is easier for the DateTimeOriginal to be altered by the system or users. So you might trust the Exif version more

BUT

if you change this line:
myArray = app.parseTags( "<ExifTool:FileCreateDate:yyyy-mm-dd-hh-m-ss>" ).split("-") ;

to:
myArray = app.parseTags( "<ExifTool:FileCreateDate:yyyy-mm-dd-hh-nn-ss>" ).split(/-| /);
myArray.pop();
console.log(myArray);

You'll get the array you seemed to be looking for.

Notes:
There was a typo. You had "-m-" when it should be "-nn'"
The .pop() is needed because the tag parse puts a "-00 " (¿milliseconds?) at the end of the FileCreateDate string. At least in version 4.19

Regards,
Randy
Reply to #1:
Date formatting is not available for ExifTool values. Use instead native values, like this:
<Date Created:yyyy-mm-dd-hh-nn-ss>

If you are using Script method, you don't have to use app.parseTags at all.
var d = item.createdDate;
console.log(d);
var dStr = app.formatDate(d, 'yyyy-mm-dd-hh-nn-ss');
console.log(dStr);

(Note, this script requires version 4.17 or newer)