Last active
December 24, 2015 20:39
-
-
Save stig/6859521 to your computer and use it in GitHub Desktop.
A script I used to consolidate and de-duplicate lots of pictures and movies from various iPhoto libraries and random folders full of images.
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 | |
set -e | |
# set -x | |
src=$1 | |
dst=$2 | |
find "$src" -type f | while read file ; do | |
chksum=$(md5 -q "$file") | |
dir=$(echo $chksum | cut -b1-2) | |
suffix=$(echo $file | awk -F. '{print tolower($NF)}') | |
to=$dst/$dir/$chksum.$suffix | |
if ! test -f "$to" ; then | |
# Make sure destination dir exists... | |
mkdir -p $dst/$dir | |
link "$file" "$to" | |
fi | |
log="$chksum $file" | |
echo $log >> "$dst/log" | |
echo $log | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment