How to set times to UTC dynamically?

Started by Wernfried, November 02, 2017, 11:37:21 AM

Previous topic - Next topic

Wernfried

Hi

I have some Exif data like this:


c:\Temp>exiftool -s -G -OffsetTime* -AllDates IMG_xxx.jpg
[EXIF]          OffsetTime                      : +08:00
[EXIF]          OffsetTimeOriginal              : +08:00
[EXIF]          DateTimeOriginal                : 2017:09:10 13:50:03
[EXIF]          CreateDate                      : 2017:09:10 13:50:03
[EXIF]          ModifyDate                      : 2017:10:03 00:36:06


I like to set all times to UTC time. Doing this manually is not problem with
exiftool -OffsetTime*=+00:00 -AllDates-=8 IMG_xxx.jpg

Now I like to do it dynamically based on "OffsetTimeOriginal". I tried several commands, e.g.
exiftool "-AllDates<${DateTimeOriginal}-${OffsetTimeOriginal}" -OffsetTime*=+00:00  IMG_xxx.jpg
but times are not changed.

Any idea how to achieve this?








Phil Harvey

I think this may do what you want:

exiftool "-exif:AllDates-<${OffsetTimeOriginal;s/^\+// or $_=undef}" "-exif:AllDates+<${OffsetTimeOriginal;s/^\-// or $_=undef}" "-offsettime*=+00:00" FILE

The command is complicated a bit so it will handle both positive and negative time zones.  Also, I am only changing EXIF dates because XMP dates should have their own time zones.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Wernfried