Created
January 13, 2016 10:32
-
-
Save nicnocquee/5a24bd6ac8b92cceab33 to your computer and use it in GitHub Desktop.
Script to organize photos by grouping them into folders of year and month of date taken. Requires imagemagick.
This file contains hidden or 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 | |
function readImage () { | |
if [ "$1" != "." ] ; then | |
DIRTOMAKE=`identify -verbose "$1" | grep exif:DateTime: | sed 's/exif\:DateTime\: //g' | sed 's/\:[0-9][0-9] [0-9][0-9]\:[0-9][0-9]\:[0-9][0-9]//g' | sed 's|:|/|g'` | |
trimmed=`echo "$DIRTOMAKE" | xargs` | |
if [ -z "$trimmed" ] ; then | |
trimmed="Unknown" | |
fi | |
echo "Moving $1 to $trimmed ..." | |
mkdir -p "${trimmed}" | |
mv -n "$1" "${trimmed}" | |
fi | |
} | |
export -f readImage | |
find "$1" -maxdepth 1 -iregex ".*\.[PNG|JPG|jpeg]*" -execdir bash -c 'readImage "$0"' {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment