#!/bin/sh

help(){
    cat <<END
Usage: $0 [options] <filename.[orf]>
Options:
    -h        Print this help message
END
    exit 0
}

while getopts h name "$@"
do
    case $name in
*)
    help ;;
    esac
done
let shiftind=$OPTIND-1
shift $shiftind

for n in "$@"
do
	case $n in
	*.orf)
		input="$n"
		base=`echo $input | sed "s/\.orf$//"` ;;
	*)
		help ;;
	esac
	echo Converting $input to $base.jpg...
	dcraw -w $input
	ppmtojpeg $base.ppm >$base.jpg
done
