Skip to content

Instantly share code, notes, and snippets.

@stephen-james
Created June 9, 2014 20:01
Show Gist options
  • Select an option

  • Save stephen-james/7c38d63718035560d290 to your computer and use it in GitHub Desktop.

Select an option

Save stephen-james/7c38d63718035560d290 to your computer and use it in GitHub Desktop.
Upload Photos to Dropbox bash script
#!/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