ExifTool Forum

ExifTool => Newbies => Topic started by: DavidB42 on March 07, 2020, 12:06:21 PM

Title: [Comment] tag contains timestamp=1566254377. How to convert?
Post by: DavidB42 on March 07, 2020, 12:06:21 PM

[FileType]               GIF
[Type]                    GPhotosAnimation
[FileModifyDate   ]  2019:10:13 21:23:09-04:00
[OriginalDateTime]  missing

I believe that the original image date of a GIF created by Google photos is stored in the [comment] tag.
(thank you, I think, Google)

[Comment]             timestamp=1566254445       (looks to be unix time stamp equivalent to 08/19/2019 @ 10:40pm (UTC))

I need help with command for parsing this comment and storing result into tag [OriginalTmeDate]

Thank you
Title: Re: [Comment] tag contains timestamp=1566254377. How to convert?
Post by: StarGeek on March 07, 2020, 12:17:39 PM
Try this:
exiftool -d "%s" "-DateTimeOriginal<${comment;m/timestamp=(\d+)/i;$_=$1}" /path/to/files/

This command parses the Comment tag for the string of digits and sets Comment equal to that value.  The -d (dateFormat) option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat) tells exiftool that the date will be formatted as a Unix timestamp.  It will then copy that value into DateTimeOriginal.

C:\>exiftool -g1 -a -s -comment -DateTimeOriginal y:\!temp\Test4.jpg
---- File ----
Comment                         : timestamp=1566254445

C:\>exiftool -P -overwrite_original -d "%s" "-DateTimeOriginal<${comment;m/timestamp=(\d+)/i;$_=$1}" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -DateTimeOriginal y:\!temp\Test4.jpg
---- ExifIFD ----
DateTimeOriginal                : 2019:08:19 22:40:45
Title: Re: [Comment] tag contains timestamp=1566254377. How to convert?
Post by: StarGeek on March 07, 2020, 12:23:08 PM
Ooops, I just noticed that your image was a GIF.  I had assumed that it was a misspelling of DateTimeOriginal.  I haven't seen a OriginalDateTime tag before and it's not documented in the Tag Names section (https://exiftool.org/TagNames/).  It may not be writable.

edit:  Actually is that even exiftool output?
Title: Re: [Comment] tag contains timestamp=1566254377. How to convert?
Post by: DavidB42 on March 07, 2020, 07:08:58 PM
Thank you so much - it is perfect

on "OrignalDateTime"  it is my dyslexic construction. 
You are right,  I should have said, DateTimeOriginal.

I don't fully understand the process, but that is because I am a zero on Perl.
I suspect I should change that.

This is the best forum I have used in a long time.
Thanks again