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 "$@"
do
	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
done

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

    Douglas Brace
    3 weeks 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 weeks 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.

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)