Check time zone in multiple tags, update if different than what it should be

Started by Ale, October 30, 2021, 05:44:47 PM

Previous topic - Next topic

Ale

Hello forum,

I've got a set of photos that were taken with different cameras, and there are some time zone discrepancies in the date/time tags. I'd like to use exiftool to iterate through the photos, check the time zone part of the date/time string in multiple tags and, if it is different than what it should be, then correct it.

I'm starting with exiftool, I see it has great potential and this is likely feasible, although I'm struggling with the how. I'd appreciate any help you may provide.

Cheers!



StarGeek

Quote from: Ale on October 30, 2021, 05:44:47 PMif it is different than what it should be, then correct it.

How are you checking to see if it's different?  If you're comparing against a static value, for example, if OffsetTimeOriginal is not equal to -07:00, then that can be handled directly with the -if option.
exiftool -if "$OffsetTimeOriginal ne '-07:00' " -OffsetTimeOriginal=-07:00 /path/to/files/

Otherwise it would be more complex or require scripting instead of a direct command.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Ale

Hi StarGeek,

Thanks for the very quick reply.
Yes, the correct time zone is a static value which I would pass as an argument (+00:00). But, it is not stored in a tag, I just checked a photo and the OffsetTimeOriginal tag does not exist.

I was aiming at a way of checking the date/time tags that may have the incorrect time zone, for example:
[XMP]           DateTimeOriginal                : 2011:03:06 10:31:15-03:00

and then have Exiftool change the "-03:00" part of the string for "+00:00".


If this gets too complex then maybe a way to go is to write the command for a single tag (not multiple at a time), and then I'd manually change it to check the next one after it checks that one for all photos. Then, repeat until I've gone through all the target tags.

Cheers!

Ale

Hi StarGeek,

I think I may get away with this using your suggestion in this post:

https://exiftool.org/forum/index.php?topic=9697.msg50398#msg50398

I just tested and set OffsetTimeOriginal in my test photo, and now SubSecDateTimeOriginal shows up.

I can use Exiftool to copy SubSecDateTimeOriginal's value into all tags under suspicion, which would give me the result I'm looking for.

Thanks for the help! :)

StarGeek

Here's an alternative.  This assumes that there is an XMP:DateTimeOriginal tag that includes a trailing time zone
exiftool -if "$XMP:DateTimeOriginal# ne $XMP:DateTimeOriginal" -api "filter=s/-03:00$/+00:00/" -TagsFromFile @ -Time:All /path/to/files/

This uses the -api Filter option to edit all tags that end with -03:00 and change that part to +00:00.  It does this as the tags are read only, exiftool hasn't written anything yet.  It then compares this edited value to the original DateTimeOriginal (indicated by the trailing hashtag, see the -n (--printConv) option) and if they are different, proceeds to copy all time related tags back into the file using the new edited values.

Doing this allows to bulk edit all the time related tags that might be in the file.  The drawback is that you do need to find a standard tag that will have the incorrect time zone in all the files.

But I also approve of actually setting the OffsetTimeOriginal and copying the SubSecDateTimeOriginal.  This is pretty much what I do.  And if you want to feel complete, you could set all three time zone tags at once with
-OffsetTime*=-00:00
That will set OffsetTime, OffsetTimeOriginal, and OffsetTimeDigitized.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Ale

Hi StarGeek:

QuoteThe drawback is that you do need to find a standard tag that will have the incorrect time zone in all the files.

If I understood your proposal correctly, then this would not be an issue as all suspect tags are present in all target photos, and the ones with the incorrect time zone will be corrected while the ones with the correct time zone will be unaffected. So, this is actually the solution to my time zone issue. Thank you very much for this!

In between posts I tried out the other solution, copying SubSecDateTimeOriginal, and the outcome is also what I was aiming to achieve. It's less efficient than your suggestion above (because it will edit tags that are incorrect as well as tags that are correct), but still works. Since its within my level of understanding of Exiftool, I'm going with this one right now. And yes I will definitively follow your tip and set all three time zones at once, so that the metadata is properly populated.

Thank you very much for your great support!  :)