Created
June 9, 2014 20:01
-
-
Save stephen-james/7c38d63718035560d290 to your computer and use it in GitHub Desktop.
Upload Photos to Dropbox bash script
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/bash | |
| echo "iPhoto Dropbox Backup v0.1"; | |
| echo "==================="; | |
| echo ""; | |
| RUNLOG="./uploader_runlog.txt" | |
| COUNTER=0 | |
| if [ ! -f $RUNLOG ]; then | |
| dropbox_uploader.sh download $RUNLOG $RUNLOG | |
| fi | |
| find ./ -name "*.jpg" -print0 -o -name "*.JPG" -print0 | while read -d $'\0' CURRENTFILE | |
| do | |
| if [ -h "$CURRENTFILE" ] | |
| then | |
| echo "file " $CURRENTFILE " is a symlink" | |
| else | |
| if $( grep -Fxq "$CURRENTFILE" "$RUNLOG" ); then | |
| echo "file " $CURRENTFILE "has already been uploaded" | |
| else | |
| echo "\tfound" $CURRENTFILE | |
| NEWFILENAME=$( echo $CURRENTFILE | sed "s/[\.\/]//g" | sed "s/jpg/.jpg/g" | sed "s/JPG/.jpg/g" ) | |
| echo "\tnew name" $NEWFILENAME | |
| echo "\tfetching exif data" | |
| EXIFDATA=$(exiv2 "$CURRENTFILE" | grep timestamp) | |
| read X X YEAR MONTH DAY HOUR MINUTE SECOND <<<${EXIFDATA//:/ } | |
| TIMESTAMPEDFILENAME=$YEAR$MONTH$DAY$HOUR$MINUTE"_"$NEWFILENAME | |
| echo "\tuploading to " $TIMESTAMPEDFILENAME | |
| dropbox_uploader.sh upload "$CURRENTFILE" "$TIMESTAMPEDFILENAME" && echo $CURRENTFILE >> $RUNLOG | |
| fi | |
| fi | |
| done | |
| dropbox_uploader.sh upload $RUNLOG $RUNLOG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment