Skip to content

Instantly share code, notes, and snippets.

@pal
Created March 20, 2011 21:16
Show Gist options
  • Save pal/878688 to your computer and use it in GitHub Desktop.
Save pal/878688 to your computer and use it in GitHub Desktop.
All-in-one script for organizing my massive amount of images. Still not stream-lined for images sans EXIF data and movies.
#!/bin/sh
# Complete script for organizing pictures and removing duplicates
# Setup some constants
SRC_DIR=${1:-"$HOME/Pictures"} # defaults to "$HOME/Pictures" or file argument
DEST_DIR="$HOME/Backuped/originals/pictures"
# use exiftool to organize all pictures, yay!
# http://www.sno.phy.queensu.ca/~phil/exiftool/
exiftool -r -d "$DEST_DIR/%Y/%m/%d/%Y-%m-%d_%H.%M.%S%%-c.%%e" "-filename<datetimeoriginal" $SRC_DIR
temp_file="/tmp/fl$$" # $$ is process ID
find "$DEST_DIR" -type f -exec shasum {} \; | sort -r > $temp_file
# use substr($0, index($0, " ")); instead of $2 to handle filenames with spaces
awk 'a[$1]++ {gsub(/^\*/,"",$2); print "rm ", substr($0, index($0, " "));}' $temp_file | sh
exiftool -r "-DateTimeOriginal>FileModifyDate" "$DEST_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment