#! /bin/bash

#photoSrcPath=/media/sd-reader
photoSrcPath=/media/panasonic_DMC-FX07

incomingPath=~/pictures/incoming

echo
pushd $incomingPath

echo
echo "Mounting $photoSrcPath"
mount $photoSrcPath

echo
echo "Copying files..."
find $photoSrcPath -iregex ".*\.jpg" -exec cp -v {} "$incomingPath/" \;

echo
echo "Unmounting $photoSrcPath"
umount $photoSrcPath

echo
echo "Renaming icky caps .JPG extensions to .jpg"
perl-rename -v 's/\.JPG$/.jpg/' *.JPG

echo
echo "Changing permissions to NOT executable"
chmod -v a-x *.jpg

echo
echo "Repairing rotation information where necessary"
jhead -autorot *.jpg

#echo
#echo "Linking photos properly with the rest"
#photoname ~/pictures/photos *.jpg

#echo
#echo "If all went well, you may now wish to remove the hard links that"
#echo "remain in this directory."

echo
popd
