Updating Exif date/time to be read by iPhoto

Started by granitechief83, July 13, 2021, 10:03:07 AM

Previous topic - Next topic

granitechief83

I'm in the process of downloading photos from Flickr, and what I've found is that some of the jpeg's do not contain correct date/time stamps.   In the photos that do not contain correct date/time stamps, the correct date/time stamp exists in the Metadata Date field in the Exif, as well as in the supplied json files, which are provided by flickr.   This only applies to some of the photos, not all.

So what I would like to do is come up with a simple script that performs the following:

1.  Reads in all files in a group of folders
2.  Checks if the files have an incorrect Date/Time stamp (which is the date I downloaded files from flickr)
3.  If file has incorrect Date/Time stamp, update the Date/Time stamp in jpeg using information in Metadata Date field or json file.   This may include writing a new field or updating existing field.

Here is an example of jpeg with incorrect Date/Time stamp.  When imported into iPhoto, this file shows as if it were taken in 2021.   It was taken in 2012.

MacBook-Pro-2:72157712385911303_b6c05bde3996_part1 matto$ exiftool -h ../data-download-3/7674757786_889790c87f_o.jpg
<!-- ../data-download-3/7674757786_889790c87f_o.jpg -->
<table>
<tr><td>ExifTool Version Number</td><td>12.29</td></tr>
<tr><td>File Name</td><td>7674757786_889790c87f_o.jpg</td></tr>
<tr><td>Directory</td><td>../data-download-3</td></tr>
<tr><td>File Size</td><td>9.4 MiB</td></tr>
<tr><td>File Modification Date/Time</td><td>2021:07:10 18:45:30-07:00</td></tr>
<tr><td>File Access Date/Time</td><td>2021:07:11 12:42:07-07:00</td></tr>
<tr><td>File Inode Change Date/Time</td><td>2021:07:11 11:40:29-07:00</td></tr>
<tr><td>File Permissions</td><td>-rw-r--r--</td></tr>
<tr><td>File Type</td><td>JPEG</td></tr>
<tr><td>File Type Extension</td><td>jpg</td></tr>
<tr><td>MIME Type</td><td>image/jpeg</td></tr>
<tr><td>Exif Byte Order</td><td>Little-endian (Intel, II)</td></tr>
..
<tr><td>Metadata Date</td><td>2012:07:29 21:53:31-07:00</td></tr>
...
</table>

The correct date/time information is only in the Metadata Date field.   The other date/time fields are incorrect.   

In the photos that seem to import fine into iPhoto, the field "Date/Time Original" seems to be the one that's correct, but that field is not present in the incorrect jpeg Exif data.

I don't want to screw this up, and that's why I'm posting here.   

Thanks in advance for any suggestions.

StarGeek

Can you post the output of this command, without all the useless HTML
exiftool -time:all -G1 -a -s file.jpg
Then select the output and hit the [code][/code] button above which is .  The result if you hit the preview button below would be something like this
======== y:/!temp/Test4.jpg
[IFD0]          ModifyDate                      : 2021:07:13 07:30:06
[ExifIFD]       DateTimeOriginal                : 2021:07:13 07:30:06
[ExifIFD]       CreateDate                      : 2021:07:13 07:30:06


Quote from: granitechief83 on July 13, 2021, 10:03:07 AM
The correct date/time information is only in the Metadata Date field.   The other date/time fields are incorrect.

It would be rather odd for that field, which is not EXIF but is XMP, to hold a correct timestamp, as that is the time that a program such as Lightroom changed/updated metadata. But if that is the most correct timestamp, then you could use this command
exiftool -wm cg '-DateTimeOriginal<MetadataDate' /path/to/files/
The -wm (-writeMode) option with cg parameters means that exiftool will only create new tags and if there is an existing DateTimeOriginal tag it will not be overwritten.

Test it out on a few files first.  Test files that showed the correct date as well as missing the date to make sure it works as you need.
"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

granitechief83

Thanks StarGeek.   Here is the formatted output.

MacBook-Pro-2:72157712385911303_b6c05bde3996_part1 matto$ exiftool -time:all -G1 -a -s ../data-download-3/7674757786_889790c87f_o.jpg
[System]        FileModifyDate                  : 2021:07:10 18:45:30-07:00
[System]        FileAccessDate                  : 2021:07:11 12:42:07-07:00
[System]        FileInodeChangeDate             : 2021:07:11 11:40:29-07:00
[ICC-header]    ProfileDateTime                 : 1998:02:09 06:49:00
[XMP-xmp]       MetadataDate                    : 2012:07:29 21:53:31-07:00


And here is the output after update:

MacBook-Pro-2:72157712385911303_b6c05bde3996_part1 matto$ exiftool -time:all -G1 -a -s ../data-download-3/7674757786_889790c87f_o.jpg
[System]        FileModifyDate                  : 2021:07:15 06:11:07-07:00
[System]        FileAccessDate                  : 2021:07:15 06:11:09-07:00
[System]        FileInodeChangeDate             : 2021:07:15 06:11:07-07:00
[ExifIFD]       DateTimeOriginal                : 2012:07:29 21:53:31
[ICC-header]    ProfileDateTime                 : 1998:02:09 06:49:00
[XMP-xmp]       MetadataDate                    : 2012:07:29 21:53:31-07:00


It looks DateTimeOriginal was updated to the date I wanted.   I know this isn't the exact timestamp, but it's more accurate now.

Thanks so much.

granitechief83

#3
I've noticed that some of my files don't have any useful dates.   In those cases, what do you suggest?  I know roughly the month and year, but not day and time.   

StarGeek

Looking at the filename, it appears to be of the type that you would originally get from Instagram/Facebook, which is numbers and letters A-F (legal hexadecimal characters) ending with _o.<ext>.  It's quite likely that there wasn't any embedded timestamps to begin with, as many social media platforms strip away all metadata.

The best course of action, IMO, is to fill in what date info you can and set the rest to the minimum.  So if you knew the year and month was April 2021, then you would set it to midnight April 1st.
-DateTimeOriginal=2021:04:01 00:00:00

Not much you can do to automate that.  You could set up a CSV spreadsheet file and fill in the data or use some sort of program with a GUI interface such as Adobe Bridge (which is free).
"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

granitechief83

OK, thanks.   That makes sense.

Another follow-up question.  One thing I've noticed is that some files have a DateTimeOriginal value set to NULL.   How can I conditionally check for this condition, and override with a fixed date?

======= ./p1012152_28529203117_o.jpg
[ExifIFD]       DateTimeOriginal                : 0000:00:00 00:00:00

StarGeek

You could use
exiftool -if '$DateTimeOriginal=~/0000:00:00 00:00:00/' <more option>

That will use RegEx to check the entire contents.
"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