Add OffsetTime based on CET or CEST time

Started by Cavallonzi, November 05, 2024, 07:48:13 PM

Previous topic - Next topic

Cavallonzi

Is there a way to add OffsetTime +2 CEST or +1 CET based on the date when the picture was taken? When my camera cant get a good GPS signal it simply doesn add any offset time to my pictures, so i want a command that reads when the pictures have been taken and then adds +2 or +1 accordingly. All the picture are taken on the same european country. I've tried asking chatgpt about it but the script it gave me didnt work.

Phil Harvey

It would maybe help if you told us what system you are using because some time zone features don't work in Windows.

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

Cavallonzi

Quote from: Phil Harvey on November 05, 2024, 07:55:59 PMIt would maybe help if you told us what system you are using because some time zone features don't work in Windows.

- Phil

i'd prefer using windows but i'm ok spinning up a linux vm if it's needed

Phil Harvey

OK.  On Mac/Unix a command like this should work:

exiftool "-filemodifydate<modifydate" -execute "-offsettime<filemodifydate" -common_args -api timezone=america/los_angeles FILE

Of course, you need to change "america/los_angeles" to the identifier of the time zone where your pictures were taken.

Here I'm setting the FileModifyDate from the EXIF ModifyDate, and using the system to tell me the correct offset for the specified time zone, then copying this back to the EXIF OffsetTime.

Unfortunately the API TimeZone option doesn't handle TZ identifiers in Windows.  It seems to only handle numerical offsets.  I have no idea why.

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

Cavallonzi

This does work but you need to change timezone=america/los_angeles in to timezone=America/Los_Angeles otherwise it will set the offset time to +0

Phil Harvey

Interesting.  What O/S?

Yes.  I was lazy with my capitalization, but it worked on my system (MacOS) so I surmised that it didn't matter.  A wrong assumption I guess.

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