Accidentally corrupted date/time on import (~2000 pictures)

Started by tobbegraf, June 22, 2022, 04:07:32 PM

Previous topic - Next topic

tobbegraf

Hi,

i hope you frinedly exiftool users can help me.
I've used exiftool many times, but struggle to find the right command for my problem.

This evening i detected, that on all imports in digikam from the last 8 months, i had accidentally set the option to "correct" the date/time values.
All date/time values are set to the import date/time.
The only remains from the original date/time are in the filename and in the Tag "Panasonic Date Time" (Camera: Panasonic GX80).

I desperately tried for the last hours to build a command, that copy this correct date to all other fields.

Example:
Filename 2021.11.24_18-42-57_kids_0716.JPG


exiftool 2021.11.24_18-42-57_kids_0716.JPG | grep -i Date
File Modification Date/Time     : 2022:01:02 13:19:05+01:00
File Access Date/Time           : 2022:01:01 22:24:15+01:00
File Inode Change Date/Time     : 2022:06:22 21:59:54+02:00
Modify Date                     : 2022:01:01 22:13:37
Date/Time Original              : 2022:01:01 22:13:37
Create Date                     : 2022:01:01 22:13:37
Panasonic Date Time             : 2021:11:24 18:42:57.47  #RIGHT!!!!
Date/Time Digitized             : 2022:01:01 22:13:37
Date/Time Modified              : 2022:01:01 22:13:37
Metadata Date                   : 2022:01:01 22:13:37
Date Created                    : 2022:01:01
Digital Creation Date           : 2022:01:01
Create Date                     : 2022:01:01 22:13:37.473
Date/Time Original              : 2022:01:01 22:13:37.473
Modify Date                     : 2022:01:01 22:13:37.473
Date/Time Created               : 2022:01:01 22:13:37+00:00
Digital Creation Date/Time      : 2022:01:01 22:13:37+00:00


I've tried man command line, but all failed:


exiftool "-time:all<$filename" * #tried in many variations
exiftool "-Time:all<$Panasonic:DateTime" * #tried in many variations


I get it working with "-AllDates<filename", but the XMP and IPTC tags are still wrong.
I can't get it working with time:all :-(

i would be happy, if anyone here has a tip or a working command.

Thanks
Tobias

StarGeek

You normally don't want to write to Time:All, as that will create dozens of extra time related tags that may not be appropriate for an image file. A quick check shows it creates 89 time related tags in a jpg.  Also, there are some things to watch for when doing so.  See the exception at the bottom of Common Mistake #5.

Also, a better command to see the timestamps would be
exiftool -time:all -G -a -s file.jpg
When you grep on just date, there are a few time tags you will be missing, specifically the IPTC:DigitalCreationTime and IPTC:TimeCreated, as the IPTC time tags hold the date and time in separate tags.

You can write to AllDates to set the three main EXIF time stamps.  You can write to the XMP versions with XMP:AllDates.  That just leaves the IPTC time stamps and probably XMP:DateCreated, which is what is supposed to be used instead of XMP:DateTimeOriginal in the IPTC Photometadata standard.  Maybe also XMP:DateTimeDigitized, which I think is part of the older EXIF metadata for XMP standard, as the current standard uses XMP:CreateDate, which would have already been set with -XMP:Alldates

To put that all together, using wildcards to get the IPTC timestamps in one shot
exiftool "-AllDates<Filename" "-XMP:AllDates<Filename" "-IPTC:*created<Filename" "-IPTC:DigitalCreation*<Filename" "-XMP:DateCreated<Filename" "-XMP:DateTimeDigitized<Filename" file.jpg

There is one more thing to watch for and that is the IPTC time tags require a time zone. Unless specifically set, exiftool will assume the local time zone of the computer.

edit:[/tt] striked out invalid assumption on my part
"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

tobbegraf

Hi,

thank you for your fast and detailed answer!

With your information i can correct the wrong date/time information.

Before:


$ exiftool -time:all -G -a -s *
[File]          FileModifyDate                  : 2022:01:02 13:19:05+01:00
[File]          FileAccessDate                  : 2022:01:01 22:24:15+01:00
[File]          FileInodeChangeDate             : 2022:06:23 09:17:22+02:00
[EXIF]          ModifyDate                      : 2022:01:01 22:13:37
[EXIF]          DateTimeOriginal                : 2022:01:01 22:13:37
[EXIF]          CreateDate                      : 2022:01:01 22:13:37
[MakerNotes]    TimeStamp                       : 2021:11:24 17:42:57
[MakerNotes]    PanasonicDateTime               : 2021:11:24 18:42:57.47
[EXIF]          SubSecTime                      : 473
[EXIF]          SubSecTimeOriginal              : 473
[EXIF]          SubSecTimeDigitized             : 473
[XMP]           DateTimeOriginal                : 2022:01:01 22:13:37
[XMP]           DateTimeDigitized               : 2022:01:01 22:13:37
[XMP]           DateTime                        : 2022:01:01 22:13:37
[IPTC]          DateCreated                     : 2022:01:01
[IPTC]          TimeCreated                     : 22:13:37+00:00
[IPTC]          DigitalCreationDate             : 2022:01:01
[IPTC]          DigitalCreationTime             : 22:13:37+00:00
[Composite]     SubSecCreateDate                : 2022:01:01 22:13:37.473
[Composite]     SubSecDateTimeOriginal          : 2022:01:01 22:13:37.473
[Composite]     SubSecModifyDate                : 2022:01:01 22:13:37.473
[Composite]     DateTimeCreated                 : 2022:01:01 22:13:37+00:00
[Composite]     DigitalCreationDateTime         : 2022:01:01 22:13:37+00:00


After:


$ exiftool "-AllDates<Filename" "-XMP:AllDates<Filename" "-IPTC:*created<Filename" "-IPTC:DigitalCreation*<Filename" "-XMP:DateCreated<Filename" "-XMP:DateTimeDigitized<Filename" Filename

$ exiftool -time:all -G -a -s 2021.11.24_18-42-57_kids_0716.JPG_original
[File]          FileModifyDate                  : 2022:06:23 09:19:21+02:00
[File]          FileAccessDate                  : 2022:06:23 09:19:21+02:00
[File]          FileInodeChangeDate             : 2022:06:23 09:19:21+02:00
[EXIF]          ModifyDate                      : 2021:11:24 18:42:57
[EXIF]          DateTimeOriginal                : 2021:11:24 18:42:57
[EXIF]          CreateDate                      : 2021:11:24 18:42:57
[MakerNotes]    TimeStamp                       : 2021:11:24 17:42:57
[MakerNotes]    PanasonicDateTime               : 2021:11:24 18:42:57.47
[EXIF]          SubSecTime                      : 473
[EXIF]          SubSecTimeOriginal              : 473
[EXIF]          SubSecTimeDigitized             : 473
[XMP]           DateTimeDigitized               : 2021:11:24 18:42:57
[XMP]           DateTimeOriginal                : 2021:11:24 18:42:57
[XMP]           DateCreated                     : 2021:11:24 18:42:57
[XMP]           DateTime                        : 2022:01:01 22:13:37 #Still wrong
[XMP]           CreateDate                      : 2021:11:24 18:42:57
[XMP]           ModifyDate                      : 2021:11:24 18:42:57
[IPTC]          DateCreated                     : 2021:11:24
[IPTC]          TimeCreated                     : 22:13:37+00:00 #Still wrong
[IPTC]          DigitalCreationDate             : 2021:11:24
[IPTC]          DigitalCreationTime             : 22:13:37+00:00 #Still wrong
[Composite]     SubSecCreateDate                : 2021:11:24 18:42:57.473
[Composite]     SubSecDateTimeOriginal          : 2021:11:24 18:42:57.473
[Composite]     SubSecModifyDate                : 2021:11:24 18:42:57.473
[Composite]     DateTimeCreated                 : 2021:11:24 22:13:37+00:00
[Composite]     DigitalCreationDateTime         : 2021:11:24 22:13:37+00:00


I've added the xmp:DateTime field that was not updatet:


$ exiftool "-AllDates<Filename" "-XMP:AllDates<Filename" "-IPTC:*created<Filename" "-IPTC:DigitalCreation*<Filename" "-XMP:DateCreated<Filename" "-XMP:DateTimeDigitized<Filename" "-XMP:DateTime<Filename"  Filename

exiftool -time:all -G -a -s 2021.11.24_18-42-57_kids_0716.JPG_original[File]          FileModifyDate                  : 2022:06:23 09:21:22+02:00
[File]          FileAccessDate                  : 2022:06:23 09:21:22+02:00
[File]          FileInodeChangeDate             : 2022:06:23 09:21:22+02:00
[EXIF]          ModifyDate                      : 2021:11:24 18:42:57
[EXIF]          DateTimeOriginal                : 2021:11:24 18:42:57
[EXIF]          CreateDate                      : 2021:11:24 18:42:57
[MakerNotes]    TimeStamp                       : 2021:11:24 17:42:57
[MakerNotes]    PanasonicDateTime               : 2021:11:24 18:42:57.47
[EXIF]          SubSecTime                      : 473
[EXIF]          SubSecTimeOriginal              : 473
[EXIF]          SubSecTimeDigitized             : 473
[XMP]           DateTimeDigitized               : 2021:11:24 18:42:57
[XMP]           DateTimeOriginal                : 2021:11:24 18:42:57
[XMP]           DateCreated                     : 2021:11:24 18:42:57
[XMP]           DateTime                        : 2021:11:24 18:42:57
[XMP]           CreateDate                      : 2021:11:24 18:42:57
[XMP]           ModifyDate                      : 2021:11:24 18:42:57
[IPTC]          DateCreated                     : 2021:11:24
[IPTC]          TimeCreated                     : 22:13:37+00:00 #Still wrong
[IPTC]          DigitalCreationDate             : 2021:11:24
[IPTC]          DigitalCreationTime             : 22:13:37+00:00 #Still wrong
[Composite]     SubSecCreateDate                : 2021:11:24 18:42:57.473
[Composite]     SubSecDateTimeOriginal          : 2021:11:24 18:42:57.473
[Composite]     SubSecModifyDate                : 2021:11:24 18:42:57.473
[Composite]     DateTimeCreated                 : 2021:11:24 22:13:37+00:00
[Composite]     DigitalCreationDateTime         : 2021:11:24 22:13:37+00:00


The only 2 that are refusing to get right are IPTC:TimeCreated and IPTC:DigitalCreationTime. I've test it and i cannot set them via <filename. But i can set them in a second run from any of the corrected exif fields. So i can completely repair my mistake.

Many thanks!
Tobias

StarGeek

Quote from: tobbegraf on June 23, 2022, 03:39:44 AM
The only 2 that are refusing to get right are IPTC:TimeCreated and IPTC:DigitalCreationTime. I've test it and i cannot set them via <filename. But i can set them in a second run from any of the corrected exif fields. So i can completely repair my mistake.

Yeah, as I said, those require a time zone.  I thought exiftool would assume the local time zone, but that only happens when directly setting a value, not in copying from the FileName.
"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

Phil Harvey

Quote from: tobbegraf on June 23, 2022, 03:39:44 AM
The only 2 that are refusing to get right are IPTC:TimeCreated and IPTC:DigitalCreationTime. I've test it and i cannot set them via <filename. But i can set them in a second run from any of the corrected exif fields. So i can completely repair my mistake.

The reason for this is that the smart date/time parsing doesn't occur when writing a time-only value.  (If I were to implement this, it would be far too easy to parse out a nonsensical time value.)  So first you must copy the filename to a date/time tag, then once you have a properly formatted date/time value you can copy this to a time-only tag and the time part will be recognized.

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