Created
May 23, 2015 00:46
-
-
Save mranallo/7f140952ddccca369706 to your computer and use it in GitHub Desktop.
move pictures hazel 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
# Written by Panayotis Vryonis, 2013. | |
# http://blog.vrypan.net/2013/5/20/leaving-iphoto-for-dropbox/ | |
# Distributed under MIT License. | |
# <http://opensource.org/licenses/MIT> | |
fullfile=$1 | |
PHOTOS="$HOME/Dropbox/Photos" | |
filename="${fullfile##*/}" | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
dates=(`exiftool \ | |
-CreateDate \ | |
-MediaCreateDate \ | |
-DateTimeOriginal \ | |
-FileModifyDate \ | |
-d '%Y-%m-%d %H.%M.%S' \ | |
-S -s "$fullfile"`) | |
thedate="${dates[0]} ${dates[1]}" | |
filename2=$thedate | |
path2="$PHOTOS/${thedate:0:4}/${thedate:0:7}" | |
if [ ! -d "$path2" ]; | |
then | |
mkdir -p "$path2" | |
fi | |
if [ ! -f "$path2/$filename2.$extension" ] ; | |
then | |
mv "$fullfile" "$path2/$filename2.$extension" | |
else | |
i=1 | |
until [ ! -f "$path2/$filename2-$i.$extension" ]; do | |
let i+=1 | |
done | |
mv "$fullfile" "$path2/$filename2-$i.$extension" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment