Skip to content

Instantly share code, notes, and snippets.

@tryp
Created September 19, 2011 17:14
Show Gist options
  • Save tryp/1226979 to your computer and use it in GitHub Desktop.
Save tryp/1226979 to your computer and use it in GitHub Desktop.
Backup a directory of folders to Picasa using GoogleCL
#!/bin/bash
# Backup a folder of to a Picasa album
if [ ! -n "$1" ]
then
echo "Backup a directory of photos to Google Picasa"
echo "Usage: `basename $0` Album_Directory/"
exit 1
fi
set -u
set -e
dir="${1}"
album=$(basename "${dir}")
#vis can be all, private, public, or visible
vis=private
echo "Uploading directory: ${dir}"
echo "to album: ${album}"
echo "to Picasa with visibility: ${vis}"
# check to see if album exists
getlist="google picasa list-albums"
filter="cut -d, -f 1 -"
create_album=true
$getlist | $filter | while read PICASA_ALBUM ; do
if [[ "$PICASA_ALBUM" == "$album" ]]; then
echo !Album \"$album\" already exists on picasa
create_album=false
# bail out rather than risk an album with duplicates
exit 1
break
fi
done
if $create_album ; then
google picasa create --access="${vis}" "${album}"
fi
count=$(ls -U1 "${dir}"/* | wc -l)
echo Processing ${count} files...
let "i = 1"
for f in "${dir}"/*; do
echo "uploading file [$i/$count]: ${f}"
google picasa post --title="${album}" "${f}"
let "i++"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment