#!/bin/bash
# 
# This is a shell-script, which retrieves all
# images on a digital-camera using gphoto2.
# In addition it rotates the images according
# to the orientation-information in the exif-
# header, Finally it sorts the images
# to dirs according to the date information.
#
# by jochen.eppler@gmx.de
#

if [ ! -z $1 ]; then
if [ -d $1 ]; then 
    cd $1
else
    echo "$1 is not a directory!"
    exit 1
fi
fi

echo "Downloading ..."
gphoto2 -P --force-overwrite
echo "Rotating and optimizing ..."
jhead -autorot -dt *.jpg *.JPG
echo "Sorting by date ..."
images_datesort *.JPG *.jpg

echo "Done."
exit 0
