Change OSX's "created" date to match photos' creation date

Started by bbezerra, September 05, 2016, 11:21:37 AM

Previous topic - Next topic

bbezerra

Hi all,

First, thank you very much for this amazing tool. I am far from a power user, but it has helped getting out of some issues in the past. But I've been trying to figure out how to solve this problem in the past week and just can't seem to find a light!

Some background:
I am running OS X El Captain and use the Photos app to organize my photos library. Due to a past migration, I had two Photos library, which I am trying to merge. However, no matter which way I try, every time I export the files, they have the OS "Created" date and the EXIF FileModifyDate set as the time it was exported. Using ExifTool, I was able to change the FileModifyDate to match the CreateDate (piece of cake ;)) which also change the date Finder shows for "Modified" and "Last opened" but the OS "Created" date stays untouched. The issue is that when I import this file to the new library, it is sorted by the "Created" date, and there is no way to chose a different sorting method.

As an UNIX distribution, OS X has the touch command which allows anyone to modify the "Created" but this is impractical to do manually for me and my 15K photos. So I was wondering if I could get some help from the most experienced users in the form of a script or ExifTool command in order to overcome this.

Any help will be more than appreciated.

Regards

bbezerra

Alright! I might have found a solution!

After exporting the photos from the Photo Library, they all come with the current date as shown in the attachment 1.

So, using

exiftool '-FileModifyDate<CreateDate' <fileName>

I change the FileModifyDate for the time the photo was taken and get the result shown in the attachment 2.

Next, I use the GetFileInfo (which was updated with the previous command) and SetFileInfo to change the Created date, like this:

for f in *; do t="$(GetFileInfo -m "$f")"; SetFile -d "$t" "$f"; done

This will change the attribute the OS uses to list as Created date, shown below in the attachment 3.

Next step, import into Photos and DONE!

Here is a example with a test file:

Bernardos-Macbook-Pro:Photo_Library2_bck Be$ ls -lrt
total 17168
-rwxrwxrwx@ 1 Be  staff  8763112  5 Set 14:34 IMG_8028.jpg

Bernardos-Macbook-Pro:Photo_Library2_bck Be$ GetFileInfo -m IMG_8028.jpg
09/05/2016 14:34:31

Bernardos-Macbook-Pro:Photo_Library2_bck Be$ exiftool -a -u -g1 -s IMG_8028.jpg | grep -i date
FileModifyDate                  : 2016:09:05 14:34:31-03:00
FileAccessDate                  : 2016:09:05 14:34:31-03:00
FileInodeChangeDate             : 2016:09:05 14:34:31-03:00
ModifyDate                      : 2016:04:15 09:51:52
DateTimeOriginal                : 2016:04:15 09:51:52
CreateDate                      : 2016:04:15 09:51:52
CreateDate                      : 2016:04:15 09:51:52
ModifyDate                      : 2016:04:15 09:51:52
DateCreated                     : 2016:04:15 09:51:52
SubSecCreateDate                : 2016:04:15 09:51:52.32
SubSecDateTimeOriginal          : 2016:04:15 09:51:52.32
SubSecModifyDate                : 2016:04:15 09:51:52.32

Bernardos-Macbook-Pro:Photo_Library2_bck Be$ exiftool '-FileModifyDate<CreateDate' IMG_8028.jpg
    1 image files updated
Bernardos-Macbook-Pro:Photo_Library2_bck Be$ GetFileInfo -m IMG_8028.jpg
04/15/2016 09:51:52

Bernardos-Macbook-Pro:Photo_Library2_bck Be$ for f in *; do t="$(GetFileInfo -m "$f")"; SetFile -d "$t" "$f"; done


If anyone knows of a cleaner, faster way to do it, please feel free to comment!

Regards

PS: sorry about not embedding the pictures, but I wasn't able to, even after uploading them to Google Photos.

Phil Harvey

I thought that the OS X file creation date was pushed back by setting FileModifyDate via ExifTool.  See the notes for FileCreateDate here, so I am surprised that the GetFileInfo/SetFile step is necessary.

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

bbezerra

Thanks for your reply, Phil.

I was surprised too, as I had the same understanding. But I guess OS X keeps this information in some other place.

Regards and thanks for this amazing tool.