#!/bin/sh
# This Bourne shell script for GNU/Linux invokes exifiron on all
# JPEG images on a CompactFlash card, to copy them into a new directory.
# It does not copy other files on the card, such as video clips.

# This script is in the public domain.  msmakela@nic.funet.fi, 1st May 2003.

# treat all errors as fatal
set -eu

# uncomment the following line if your camera is in Universal Coordinated Time.
#TZ=UTC0;export TZ

# the mount point in /etc/fstab
MNT="/mnt/flash";
# sample /etc/fstab entry:
#/dev/hde1	/mnt/flash	vfat	defaults,user,noauto,noexec 0 0

DEV="`grep "	$MNT	" /etc/fstab | cut -f1`"
if [ -z "$DEV" ]
then
    echo "$MNT does not exist in /etc/fstab!" >&2
    exit 1
fi

# In devfs (of Linux 2.4), the /dev tree is dynamically updated.
if [ ! -e "$DEV" ]
then
    echo -n "waiting for the CompactFlash card to be plugged in" >&2
    while [ ! -e "$DEV" ]
    do
	echo -n "." >&2
	sleep 1
    done
    echo
fi

mount "$MNT"
exifiron -s "`date +"%Y-%m-%d %H:%M:%S"`" "$MNT"/dcim/*/*.jpg
umount "$MNT"
#/sbin/cardctl eject
