Apple - Export from Mac Photos app while keeping date created data?

Note that, in order for your files to have a created date that matches the EXIF "photo taken" date, you must use Export Unmodified Originals. Modified images may have been edited within Photos which results in a new file being created, and using the normal Export will export that modified file with the later creation date.

There are some options in this post on Photography SE for changing a file's creation date to match EXIF data. You should never attempt to use these on files within the .photoslibrary bundle! Export your files first.

ExifTool is a very powerful command-line application for reading and writing EXIF data in a variety of files, including videos. However, on Macs, it cannot write the file creation date. There's a way around that using a bit of bash scripting.

Here's a command that will work for both photo and video files:

for file in *; do SetFile -d "$(exiftool -p '$CreateDate' -d '%m/%d/%Y %H:%M:%S' "$file")" "$file"; done

Essentially a loop is run over files in the current directory. exiftool is used to read the EXIF creation date tag, and SetFile is used to write as the file's creation date. The way it is written, it will affect all files in the current directory, so I suggest you move all files that you wanted modified into a directory with nothing else in it, and run the command from that directory.


Like the case of apple icloud photos, when you have all the information in the EXIF details, like you already know.

To restore all the dates information I followed this steps

  1. Download exiftool

  2. Run next command to fix the dates in all the files inside the folder(recursively)

    exiftool -r '-FileModifyDate<DateTimeOriginal' "hereYourDirName"
    
  3. If you have the No writable tags... error, this probably means that you don't have the permission, so you can fix the owner and the permission with these command

    sudo chown -R yourSessionUser directoryName
    sudo chmod -R 775 directoryName
    

This will restore all the dates. I hope that this information be useful



Now some other helping commands

To can check if your file has all the EXIF information you can check it with this command. Useful to be sure that you have the DateTimeOriginal with the right date.

exiftool -a -s -G directoryName

If you want to update the EXIF just on some extensions, for example just photos, you can use this commands. Useful if you have a los of mov files or files without the EXIF information, like this you will skip them, you will not have a warning and the exiftool will finish faster.

  1. Generate the file called filesToUpdate.txt with the list of files that you want to update.

    find hereTheAbsolutePathToTheFolder/* -type f | grep -E
    '\.(jpg|jpeg|png|heic|JPG|JPEG|PNG|HEIC)$' > filesToUpdate.txt
    

The list of jpg|jpeg|png|heic|JPG|JPEG|PNG|HEIC, is the list of extensions that you want to consider.

  1. Now the command to run all this files is like this:

    exiftool '-FileModifyDate<DateTimeOriginal' -@ filesToUpdate.txt
    

This command is to check which extensions files you have in a folder. Useful to check which extensions you want to include in previous command.

find hereThePathToTheFolderThat/* -type f | 
perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u

Tags:

Macos

Photos

Mac