ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: aagoela on December 26, 2021, 02:01:13 PM

Title: Add Timezone to a TAG when it doesn't exist
Post by: aagoela on December 26, 2021, 02:01:13 PM
Apologies on a very basic question.  I've tried to find this specific answer without any luck.

I would like to add -2:30 to the Keys:CreationDate TAG (currently this is empty).

I've tried many different things without any luck including the following:

exiftool "-Keys:CreationDate+=0000:00:00 00:00:00-02:30" -ext mov -o OUTDIR/  D:\Software\EXIFtool\OUTDIR\OUTDIR

I've had some success with MP4Workshop in this regard, but it modifies more TAGS than I'd like.  Hopefully I'm just missing some simple syntax for exiftool to be able to handle it.

Here's what the file shows currently with "exiftool -a -G1 -s -api QuickTimeUTC=1 -time:all 1.mov:

[System]        FileModifyDate                  : 2021:08:14 15:47:38-04:00
[System]        FileAccessDate                  : 2021:12:26 13:34:25-05:00
[System]        FileCreateDate                  : 2021:08:14 15:47:38-04:00
[QuickTime]     CreateDate                      : 2021:08:14 15:47:38-04:00
[QuickTime]     ModifyDate                      : 2021:08:14 15:47:38-04:00
[Track1]        TrackCreateDate                 : 2021:08:14 15:47:38-04:00
[Track1]        TrackModifyDate                 : 2021:08:14 15:47:38-04:00
[Track1]        MediaCreateDate                 : 2021:08:14 15:47:38-04:00
[Track1]        MediaModifyDate                 : 2021:08:14 15:47:38-04:00
[Track2]        TrackCreateDate                 : 2021:08:14 15:47:38-04:00
[Track2]        TrackModifyDate                 : 2021:08:14 15:47:38-04:00
[Track2]        MediaCreateDate                 : 2021:08:14 15:47:38-04:00
[Track2]        MediaModifyDate                 : 2021:08:14 15:47:38-04:00
[ItemList]      ContentCreateDate               : 2021:08:14 15:47:38-02:30
[Keys]          CreationDate                    : 2021:08:14 15:47:38

The motivation is to allow proper Google Photos sorting between photos and videos.

My initial step was to generate the Keys:CreationDate TAG with the following: exiftool -api QuickTimeUTC "-System:FileCreateDate<ItemList:ContentCreateDate" "-Keys:CreationDate<ItemList:ContentCreateDate" "-TrackCreateDate<ItemList:ContentCreateDate" "-MediaCreateDate<ItemList:ContentCreateDate" "-Quicktime:CreateDate<ItemList:ContentCreateDate" "-Quicktime:ModifyDate<ItemList:ContentCreateDate" "-TrackModifyDate<ItemList:ContentCreateDate" "-MediaModifyDate<ItemList:ContentCreateDate" "-FileModifyDate<ItemList:ContentCreateDate" -d %Y-%m-%d_%H.%M.%S.%%e -ext mp4 -ext mov -o OUTDIR/  D:\Software\EXIFtool\OUTDIR

For whatever reason, the -02:30 timezone didn't carry over.

Thanks in advance.
Title: Re: Add Timezone to a TAG when it doesn't exist
Post by: StarGeek on December 26, 2021, 02:11:19 PM
Try
exiftool "-Quicktime:CreationDate<$CreationDate -02:30" /path/to/files/

Example output:
C:\>exiftool -G1 -a -s -CreationDate Y:\!temp\Test1.mp4
[Keys]          CreationDate                    : 2021:08:14 15:47:38

C:\>exiftool -P -overwrite_original "-Quicktime:CreationDate<$CreationDate -02:30" Y:\!temp\Test1.mp4
    1 image files updated

C:\>exiftool -G1 -a -s -CreationDate Y:\!temp\Test1.mp4
[Keys]          CreationDate                    : 2021:08:14 15:47:38-02:30


Quicktime:CreationDate is not an integer based tag like Quicktime:CreateDate is, so it is usually set to local time instead of UTC.  The -api QuickTimeUTC option (https://exiftool.org/ExifTool.html#QuickTimeUTC) isn't necessary when writing it, but it won't hurt it either.
Title: Re: Add Timezone to a TAG when it doesn't exist
Post by: aagoela on December 26, 2021, 03:16:27 PM
Amazing.  Thank you very much!

This made exactly the modification I needed.  The MOV timestamp now aligns with JPG timestamps in Google Photos!

I don't understand the logic though.  For my own learning/understanding:

1) What does the "$" in front of CreationDate signify?
2) Quicktime:CreationDate somehow maps to Keys:CreationDate?

Using:
exiftool "-Quicktime:CreationDate<$CreationDate -02:30" "-FileModifyDate<System:FileCreateDate" -ext mov -o OUTDIR/  D:\Software\EXIFtool\OUTDIR\OUTDIR

Here are the new tags:


[System]        FileModifyDate                  : 2021:08:14 15:47:38-04:00
[System]        FileAccessDate                  : 2021:12:26 14:59:25-05:00
[System]        FileCreateDate                  : 2021:08:14 15:47:38-04:00
[QuickTime]     CreateDate                      : 2021:08:14 15:47:38-04:00
[QuickTime]     ModifyDate                      : 2021:08:14 15:47:38-04:00
[Track1]        TrackCreateDate                 : 2021:08:14 15:47:38-04:00
[Track1]        TrackModifyDate                 : 2021:08:14 15:47:38-04:00
[Track1]        MediaCreateDate                 : 2021:08:14 15:47:38-04:00
[Track1]        MediaModifyDate                 : 2021:08:14 15:47:38-04:00
[Track2]        TrackCreateDate                 : 2021:08:14 15:47:38-04:00
[Track2]        TrackModifyDate                 : 2021:08:14 15:47:38-04:00
[Track2]        MediaCreateDate                 : 2021:08:14 15:47:38-04:00
[Track2]        MediaModifyDate                 : 2021:08:14 15:47:38-04:00
[ItemList]      ContentCreateDate               : 2021:08:14 15:47:38-02:30
[Keys]          CreationDate                    : 2021:08:14 15:47:38-02:30


No worries if it's too much to explain.  I'm just happy it's finally working (after MANY hours of fiddling).
Title: Re: Add Timezone to a TAG when it doesn't exist
Post by: StarGeek on December 26, 2021, 03:45:01 PM
Quote from: aagoela on December 26, 2021, 03:16:27 PM
1) What does the "$" in front of CreationDate signify?

From the docs on the -TagsFromFile option (https://exiftool.org/exiftool_pod.html#tagsFromFile-SRCFILE-or-FMT)
     An extension of the redirection feature allows strings involving tag names to be used on the right hand side of the < symbol with the syntax "'-DSTTAG<STR'", where tag names in STR are prefixed with a $ symbol.

For operations where you want to include static data with actual tags, the dollar sign lets exiftool know that this is the start of a tag and not static data.  Also see Common Mistake #5 (https://exiftool.org/mistakes.html#M5) which describes possible pitfalls.

Quote2) Quicktime:CreationDate somehow maps to Keys:CreationDate?

Quicktime (https://exiftool.org/TagNames/QuickTime.html) is the Family 0 group. Keys, ItemList, and UserData are Family 1 groups within the Quicktime group.  Since in some cases, the same tag might be in two or even all three of the subgroups, exiftool defaults to writing ItemList, then UserData if the tag isn't available there, then finally Keys.  As CreationDate only appears in Keys, then that's where exiftool ends up writing the tag.
Title: Re: Add Timezone to a TAG when it doesn't exist
Post by: JohnJackson on January 09, 2022, 08:30:46 PM
Hi aagoela,
I'm glad you could solve your problem with the multifunctional Exiftool. It's just great that since Exiftool 11.39 it is also possible to create and edit new Quicktime tags.
I'm the author of MP4Workshop, and of course it is in no way as comprehensive as Exiftool.  MP4Workshop is aimed at changing dates and location in video files. I've added other metadata and jpg date editing because I found this handy in my own use cases.
The software indeed 'touches' several fields and also 'touches' the filesystem date. During debugging I had options to select which fields were changed, but for simplicity of the interface I've removed these options.
You describe that it modifies more tags than you would like. Could you describe a use case where you would like less tags to be changed? I could make these optional again.

Greetings, John