When exporting photos from a service like Flickr, perhaps after they've given notice that they're going to delete our photos if you don't subscribe to their paid plan, you might run into an issue where the photos you've downloaded have incorrect created and modified dates.
To fix this, we need to build a quick bash script to update all the created and modified dates from the photo's EXIF data.
We're going to be using two built in Mac OSX command line tools to do this...
First, fire up your editor of choice again and create a new file named update_file_dates.sh
Paste in the following bash script code...
for f in *.jpg; do
echo "Processing $f";
created_date_from_exif=$(mdls -raw -n kMDItemContentCreationDate "$f") # Pulls creation date from image's exif data
formated_created_date=$(date -f '%F %T %z' -j "$created_date_from_exif" '+%D %T %z') # Converts creation date to a format that can be used by the date command
SetFile -d "$formated_created_date" "$f" # Sets the file's creation date to the date pulled from the exif data
SetFile -m "$formated_created_date" "$f" # Sets the file's modification date to the date pulled from the exif data
done
Then mark the file as executable...
> chmod +x update_file_dates.sh
Then execute it...
> ./update_file_dates.sh
The script will loop over every jpg file in the current directory and update the file's creation and modification dates with the date found in the images's EXIF data.
Otherwise you can also use the excellent exiftool application developed by Phil Harvey...
> exiftool "-FileModifyDate<DateTimeOriginal" *.jpg
Sources:
- https://apple.stackexchange.com/questions/398425/change-file-creation-date-to-content-created-date-using-terminal
- https://exiftool.org/
To: @mattccrampton
0
Other Posts
All Truthy and Falsy Javascript Values In Nodejs, every value has an associated boolean, true or false, value. For example, a null value has an......
Google Forcing Nest Cameras Visual Indicator Light To Be On Received the following email from Google today... Full email text... Recently, we shared our commitment......
Posting to Twitter with Python - Part Two: Posting Photos NOTE: This is part two of my posting to Twitter with Python tutorial. If you......
Doubleclick to open a file in VIM from OSX I use VIM for just about everything from note taking to coding to keeping track of......
Sign Into Gmail Without Signing Into Google Chrome Unfortunately, Google has made changes to Chrome since this blog post was posted which removed the options......
Four Steps To Write An AppleScript to Gather ALL Windows on OSX I have no idea why, but there is no built-in way to gather......