How To Change File Creation Dates To Match Photo Metadata

When you export photos from the Photos app the date of the file doesn't match the date the photo was taken. This is correct as the file is new and the photo in it does retain the metadata with the original date. But if you want to force the file date to match the photo date, you can do it in the Terminal or with an Automator app.

Here’s the code used in this tutorial:

for f in "$@"
	touch -t $(date -j -f "%Y%m%d%H%M" -v-6H $(mdls $f | grep kMDItemContentCreationDate | head -n1 | awk '{gsub("[^[:digit:]]+"," ");print $1$2$3$4$5}') +%Y%m%d%H%M
202105271859) $f

Comments: 5 Responses to “How To Change File Creation Dates To Match Photo Metadata”

    Douglas Brace
    3 months ago

    Is it possible to do this so that the creation date is changed but not the modified date? Why am I asking? Technically speaking someone might want the creation date to be the actual original date and time from when the photo was taken but might want the modified date to be when the photo was exported (in this case, since the original was an HEIC file the export would be the JPEG version of it). If it is possible, thanks in advance. If not, I completely understand and I appreciate everything.

    3 months ago

    Douglas: That will take much more work. You’d have to save the original modified date to a variable, then recall it and set the modified date after setting the primary date.

    2 months ago

    Amazing Thank You!
    Just what I was looking for. All other guides was only about changing the date manually one file at a time.
    With this Automator I can now change thousands of files by select and drag.

    iPhone Photo app seems not to care about true metadata, and uses the file created date instead, when transferring backed up photos and videos back to iPhone.

    2 months ago

    Will this work for .mov files?

    2 months ago

    Craig: Theoretically yes. But video file metadata is different so you’ll need to research the correct things to address and perhaps do some trial and error.

Leave a New Comment Related to "How To Change File Creation Dates To Match Photo Metadata"

0/500 (500 character limit -- please state your comment succinctly and do not try to get around this limit by posting two comments)