Exported and organized 29,000 images from Mac Photos

I just migrated our 29,000 pictures from the mac Photo database to lightroom. In doing so, I exported all of the images. This resulted in every image having a creation date and modified date of today, rather than the multi years of photos that they represent.



After a bit of poking around, I found programs (jhead, exiftool) which would read the date it was shot out of the EXIF data in the header of the image and change the modified date for the file, but none of them changed the creation date of the file. It was bugging me because whenever I listed them out, they all said today's date, so I wrote a bit of code to do it.

To change the modified dates, I just used:

    jhead -ft *.jpg

It turns out that the creation date of a file is platform dependent so cross-platform libraries don't support it well.

The solution ended up being part of Apples XCode commandline tools. If you don't already have them, you will need to install them first. Then, just try typing:

    SetFile -d "MM/DD/YYYY HH:MM:SS" "path/file.jpeg"


The code walks a directory structure (including sub-directories) and creates a dictionary of all files and their modified dates. It then calls SetFile for each file, passing in the modified date to make them match. No warranty on it so please understand and edit it first if you want to use it.