Skip to content

Instantly share code, notes, and snippets.

@stoft
Last active November 29, 2022 21:17
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 stoft/0efcff8e11cc46eecc681516e07d66e4 to your computer and use it in GitHub Desktop.
Save stoft/0efcff8e11cc46eecc681516e07d66e4 to your computer and use it in GitHub Desktop.
Update file metadata from Exif metadata MacOS
#!/bin/zsh
for file in *.JPG; do
before=`GetFileInfo -d $file`
touch -mt `exiftool -s -s -s -d "%Y%m%d%H%M.%S" -DateTimeOriginal $file` $file;
var=$(exiftool -s -s -s -d "%m/%d/%Y %H:%M:%S" -DateTimeOriginal $file)
SetFile -d "$var" $file;
dir=$(exiftool -s -s -s -d "%Y/%m" -DateTimeOriginal $file)
echo "$dir/$file : $before --> `GetFileInfo -d $file`"
mkdir -p "$dir"
mv -n $file ./$dir/$file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment