Skip to content

Instantly share code, notes, and snippets.

@nukejello
Last active August 5, 2018 03:12
Show Gist options
  • Save nukejello/519f3b8c5e8452fcf9b6eb3931c410e7 to your computer and use it in GitHub Desktop.
Save nukejello/519f3b8c5e8452fcf9b6eb3931c410e7 to your computer and use it in GitHub Desktop.
exiftool: add DateOriginal to filenames (Canon CR2 and JPG) recursively in current directory (synology)
#!/bin/bash
printf "Adding date to filenames (Canon CR2 and JPG) in current directory recursively\n\n"
CWD=$(pwd)
DATE=`date '+%Y-%m-%d %H:%M:%S'`
DATELOG=`date '+%Y-%m-%d_%H%M%S'`
SECONDS=0
printf "Started at: ${DATE}\n\n" | tee ${DATELOG}-photos_exiftool_filerename.txt && exiftool -ext JPG -ext CR2 -if '$make eq "Canon"' '-testname<${DateTimeOriginal}-${filename;$_=subst($_,4);}' -d "IMG_%Y%m%d_%H%M%S%%-c" -i "@eaDir" -P -overwrite_original_in_place -v -r "${CWD}" 2>&1 | tee -a ${DATELOG}-photos_exiftool_filerename.txt
DATEEND=`date '+%Y-%m-%d %H:%M:%S'`
printf "\nEnded at: ${DATEEND}\n\n" | tee -a ${DATELOG}-photos_exiftool_filerename.txt
duration=$SECONDS
printf "Duration: $(($duration / 60)) minutes and $(($duration % 60)) seconds\n\n" | tee -a ${DATELOG}-photos_exiftool_filerename.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment