bash script to upload files from flash drive
Here’s a useful little bash script I just wrote to upload photos from my flash card reader onto my laptop. The script is specific to the flash card file system used by my Canon EOS 300D, but should easily be adaptable for other uses. It is Free Open Source Software and is released under the GNU GPL license.
#! /bin/bash
MOUNTPOINT="/mnt/flash/"
FLASH_PHOTOROOT=$MOUNTPOINT"dcim/"
LOCAL_PHOTOROOT="/home/matthew/photos/"
mount -t msdos /dev/sda1 $MOUNTPOINT
DIR_LIST=`ls $FLASH_PHOTOROOT | grep .canon`
for dir in ${DIR_LIST}
do
if [ ! -d $LOCAL_PHOTOROOT${dir} ]; then
mv -v $FLASH_PHOTOROOT${dir} $LOCAL_PHOTOROOT
else
mv -v $FLASH_PHOTOROOT${dir}/* $LOCAL_PHOTOROOT${dir}
rmdir -v $FLASH_PHOTOROOT${dir}
fi
chown -R matthew:matthew $LOCAL_PHOTOROOT${dir}
done
umount $MOUNTPOINT
