Main Menu

FileDate with Offset

Started by IronJosie, September 22, 2024, 12:29:34 PM

Previous topic - Next topic

IronJosie

I would like to adjust the FileDate to the CreateDate timestamp, which can be done like this:
exiftool "-filemodifydate<datetimeoriginal" "-filecreatedate<datetimeoriginal" .Is it possible to take the TimeOffset into account, when change the FileDate?
E.g. Picture was taken with Offset -07:00, but local computer is in +02:00 right now.

wywh

Try this:

exiftool -overwrite_original "-offsettime*=-07:00" "-filemodifydate<datetimeoriginal" "-filecreatedate<datetimeoriginal" .

exiftool -a -G1 -s -filecreatedate -filemodifydate -datetimeoriginal "-offset*" .
======== ./image.jpg
[MacOS]         FileCreateDate                  : 2001:01:01 12:00:00+02:00
[System]        FileModifyDate                  : 2001:01:01 12:00:00+02:00
[ExifIFD]       DateTimeOriginal                : 2001:01:01 12:00:00
[ExifIFD]       OffsetTime                      : -07:00
[ExifIFD]       OffsetTimeOriginal              : -07:00
[ExifIFD]       OffsetTimeDigitized             : -07:00

- Matti

Phil Harvey

The API TimeZone option may do the trick:

> exiftool a.jpg "-filemodifydate<datetimeoriginal" -api timezone=7
    1 image files updated
> exiftool a.jpg -filemodifydate -datetimeoriginal
File Modification Date/Time     : 2022:09:02 11:18:25-04:00
Date/Time Original              : 2022:09:02 08:18:25

Note that the sign of the timezone setting is opposite to what one would expect.

- 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 ($).

wywh

Oh, sorry I misread your question but Phil already provided the answer. Another option is to use TZ Identifier like America/New_York when writing and reading file dates so you don't have to change the computer's clock when doing so:

exiftool -overwrite_original -api TimeZone=America/New_York "-filemodifydate<datetimeoriginal" "-filecreatedate<datetimeoriginal" .

exiftool -a -G1 -s -api TimeZone=America/New_York -filecreatedate -filemodifydate -datetimeoriginal .
======== ./image.jpg
[MacOS]         FileCreateDate                  : 2024:06:01 12:00:00-04:00
[System]        FileModifyDate                  : 2024:06:01 12:00:00-04:00
[ExifIFD]       DateTimeOriginal                : 2024:06:01 12:00:00

https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

- Matti

Phil Harvey

I don't think that TZ names like this work in Windows.  Read here and here for previous discussions on this.

And the ExifTool documentation:

The value is a time zone offset like "+05:00" (but note that the offset is to UTC, not from UTC, so it is positive for western time zones), or a time zone name like "EST5EDT". For Unix-based systems, the value may also be a time zone ID like "America/New_York".

- 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 ($).