little bash script for grabbing photos off my canon eos 400d

i'm a gadget hound

note: works on netbsd, not necessarily elsewhere, you will need the “progress” application, a port for linux is located here. the european canon eos 400d is the same as the american canon rebel xti and the japanese eos kiss digital x. this script doesn’t care what model you have, and may very well work with other canon cameras or even other brands, as long as you change the memory card location (/dev/sd0e in this example) and the camera’s proprietary directories (/DCIM/100CANON in this example) to the correct names for your camera.

#!/bin/sh
#bash script for grabbing photos from canon eos 400d on my netbsd with a progress bar

/sbin/mount ~/dev/sd0e ~/mnt/cf/ || exit 1
date=`date ‘+%m_%d_%y’`
size=`du -kc ~/mnt/cf/DCIM/100CANON/ | tail -n 1 | cut -f 1`
mkdir -p ~/photos/$date &&
(cd ~/mnt/cf/DCIM/100CANON && tar -cf – *) | (cd ~/photos/$date && progress -l “${size}k” tar -xf -)
/sbin/umount ~/mnt/cf

Leave a Reply