Skip to content

Instantly share code, notes, and snippets.

@Jofkos
Last active August 14, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jofkos/ec4d0120e4fbe447ace42f82dca18766 to your computer and use it in GitHub Desktop.
Save Jofkos/ec4d0120e4fbe447ace42f82dca18766 to your computer and use it in GitHub Desktop.
Fixes the date from exported photos. (Sets the file-system date to the recording date from exif data)
#!/bin/bash
# Run in folder containing the pictures
for file in *
do
if [[ $(file --mime-type -b "${file}") == image/* ]]
then
touch -t "$(exiftool -createdate $file | awk -F ':| +' '{ print $5$6$7$8$9"."$10 }')" $file;
fi
done
@Jofkos
Copy link
Author

Jofkos commented Aug 14, 2017

To use when exporting files with macOS' "Photos".

@Jofkos
Copy link
Author

Jofkos commented Aug 14, 2017

Or here as one-line command (run in directory containing the pictures):

for file in *; do if [[ $(file --mime-type -b "${file}") == image/* ]]; then touch -t "$(exiftool -createdate $file | awk -F ':| +' '{ print $5$6$7$8$9"."$10 }')" $file; fi done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment