Created
March 20, 2011 18:02
-
-
Save pal/878499 to your computer and use it in GitHub Desktop.
Removes duplicate files (found using SHA1 checksum)
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/bash | |
# Used in an Automator action that is run as a Image Capture Plugin after file organization | |
#Delete duplicate files starting at $1 recursive | |
SRC_DIR=${1:-"$HOME/Backuped/originals/pictures"} # defaults to "$HOME/Backuped/originals/pictures" | |
temp_file="/tmp/fl$$" # $$ is process ID | |
find "$SRC_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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should probably do a check if images are identical sans EXIF data, and if they are, try merge of EXIF?