LJ Archive

Listing 2

#!/bin/sh
# wrapper for get_a_pic to get all pictures from
# Casio QV-10
#
prog=`basename $0`
usage() {
	echo "Usage: $prog basename [start [end]]"\
		>&2
	echo "Reads all pictures from the Casio \
QV-10 digital camera" >&2
	echo "If given, start (>=1) and end (<=96)\
limit the grab" >&2
	exit 1;
}
#
#Check at least one parameter
if [ "X$1" = "X" ]
then
	usage
fi
BASENAME=$1
START=1
if [ "X$2" != "X" ]
then
	START=$2
fi
END=96
if [ "X$3" != "X" ]
then
	END=$3
fi
trap "qvplay -r" 0
trap "qvplay -r" 2
trap "qvplay -r" 9
MAX=`qvplay -n`
set - $MAX
MAX=$3
if [ $END -gt $MAX ]
then
	END=$MAX
fi
if [ $START -lt 1 -o $END -gt 96 -o $START -gt
$END ]
then
	usage
fi
echo "Total pictures = $MAX"
NUM=$START
while [ $NUM -le $END ]
do
	# echo -ne "Getting picture $NUM...\r"

	if [ $NUM -lt 10 ]
	then
		POSTFIX=-$NUM
	else
		POSTFIX=$NUM
	fi
	get_a_pic $NUM >$BASENAME$POSTFIX.jpg
	NUM=`expr $NUM + 1`
done
echo
LJ Archive