linux flickr auto uploader

sudo perl -MCPAN -e 'install Flickr::Upload'

flickr_upload --auth

echo auth_token=<token> >> ~/.flickrrc
echo progress=0 >> ~/.flickrrc

via http://anbits.blogspot.com

#! /usr/bin/env /bash

help() {
    echo 'Runs flickr_upload on directories and subdirectories.'
    echo 'If no arguments, runs in current directory.'
    echo 'Tag is taken from directory name.'
}

DONEMARKER="flickr_upload_marker"

if [[ ($2 != "") && ($1 = "-d") ]]; then
    pushd "$2" > /dev/null
    echo `pwd`
    if [ ! -e $DONEMARKER ]; then
        pwd=`pwd`
        TAG=`basename "$pwd"`
        flickr_upload --tag "$TAG" *.jpg
        flickr_upload --tag "$TAG" *.JPG
        touch $DONEMARKER
    else
        echo "marker found \"$DONEMARKER\""
    fi
    popd > /dev/null
    exit 0
elif [[ $1 != "" ]]; then
    DIR="$1"
else
    DIR="`pwd`"
fi

help

pushd "`dirname $0`" > /dev/null
SCRIPTLOCATION="`pwd`"
popd > /dev/null

pushd "$DIR" > /dev/null
DIR="`pwd`"
popd > /dev/null

echo $DIR
find "${DIR}/" -type d -print0 | xargs -0 -I % $0 -d %