#	First, in iPhoto select all events and do Photos > Batch Change
#	Set Title to Event Name
#	With all events highlighted, export events a folder somewhere, for filename use title
#	Photos will be exported with filename of "event - number.jpg" (ex: Animals - 0004.jpg)
#	This script will create the appropriate directory structure based on those filenames
#	Set the photo_dir variable below to the full path of the directory

photo_dir=YOUR_FOLDER

cd $photo_dir

for filename in *
do

#takes the string preceding the dash, trims leading and trailing whitespace, then removes all non web-friendly characters
dir=`echo $filename | cut -d- -f1 | sed 's/^[ ]//' | sed 's/[ ]$//' | sed 's/[^A-Za-z0-9 _]//g'`

#takes the string following the dash, trims leading and trailing whitespace
file=`echo $filename | cut -d- -f2 | sed 's/^[ ]//' | sed 's/[ ]$//'`

#if directory doesn't yet exist, create it
if ! test -d "${dir}"
then
mkdir "${dir}"
fi

#move file to the appropriate directory and rename it to numeric filename
mv "${filename}" "${dir}/${file}"

done