Created
January 27, 2021 17:06
-
-
Save ascarter/ea9f843d2f4d75bcfb95b79604a979ee to your computer and use it in GitHub Desktop.
Photo re-organization script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Rearrange exported originals to a yyyy/mm camera roll for OneDrive | |
# Set options | |
while getopts "is" arg; do | |
case "${arg}" in | |
i) INFO=1 ;; | |
s) SUMMARIZE=1 ;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
src="${1:-$PWD}" | |
fmt="%Y/%m/%Y%m%d_%H%M%S" | |
pushd "${src}" | |
if [ -n "${SUMMARIZE}" ]; then | |
# Summarize | |
exiftool -csv -r "${src}" > ./camera_roll.csv | |
elif [ -z "${INFO}" ]; then | |
# Move and set tags | |
exiftool -F -r -d ${fmt} "-filecreatedate<createdate" "-filemodifydate<modifydate" '-filename<${createdate}%-c.%le' '-filename<${datetimeoriginal}%-c.%le' '-filename<${datetimeoriginal}${datetimeoriginal#;s/.*([-+]\d+):(\d+)/$1$2/ or $_=""}${subsectimeoriginal;$_.=0 x(3-length)}%-c.%le' "${src}" | |
# Remove empty directories | |
find . -r -type f -name ".DS_Store" | |
find . -type d -empty -delete | |
else | |
echo "INFO:" | |
#exiftool -r -filename -make -datetimeoriginal -subsectimeoriginal -offsettimeoriginal -subseccreatedate -filecreatedate -filemodifydate -createdate -modifydate "${src}" | |
#exiftool -r -filename -make -datetimeoriginal -filecreatedate -filemodifydate -createdate -modifydate "${src}" | |
#exiftool -F -r -d ${fmt} '-testname<${createdate}%-c.%le' '-testname<${datetimeoriginal}%-c.%le' '-testname<${datetimeoriginal}${datetimeoriginal#;s/.*([-+]\d+):(\d+)/$1$2/ or $_=""}${subsectimeoriginal;$_.=0 x(3-length)}%-c.%le' "-filecreatedate<createdate" "-filemodifydate<modifydate" "${src}" | |
exiftool -F -r -d ${fmt} '-testname<${datetimeoriginal}%-c.%le' "${src}" | |
exiftool -F -r -d ${fmt} '-testname<datetimeoriginal' "${src}" | |
fi | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment