#!/bin/sh
# shell script to download pictures to current directory
# from my digital camera
# the camera looks to the computer like a usb storage device
# the pictures on my fuji are in a directory "dcim"
# this might need to be changed for other cameras
# fstab contains the line
# /dev/sda1 /camera vfat defaults,user,noauto
# the mount directory /camera should exist
mountdir=/camera
source=/camera/dcim
destination=.
if [ ! -d $source ]
then
echo mounting the camera
if ! mount $mountdir
then
echo Is the camera attached and turned on?
exit
fi
fi
for suffix in jpg avi
do
for picture in `find $source -name \*.$suffix`
do
name=`date -r $picture +%y_%m_%d_%T`.$suffix
newname=`echo $name | sed s/:/_/g`
if [ -e $destination/$newname ]
then
echo $newname already exists, not copying
else
echo copying $picture to $newname
cp $picture $destination/$newname
chmod 644 $destination/$newname
fi
done
done
echo unmounting camera
umount /camera
echo done