#!/bin/sh PROG_NAME=$(basename $0) MOUNTPOINT=/media/camera DIRNAME=$(date +%Y%m%d-%Hh%M) print_usage() { echo "Usage: ${PROG_NAME} [OPTION]..." echo echo "Copy and delte images from digital camera." echo echo "Options:" echo " -h display this help and exit" exit 0 } while getopts "h" flag ;do case ${flag} in h) print_usage ;; ?) echo "${PROG_NAME}: Invalid option: ${OPTARG}." echo "Try \`${PROG_NAME} -h' for more information." exit 1 ;; esac done shift `expr "${OPTIND}" - 1` # `$#' now represents the number of arguments after the options. # `$1' is the first argument, etc. if [ $# -ne 0 ]; then echo "${PROG_NAME}: Too many arguments." echo "Try \`${PROG_NAME} -h' for more information." exit 1 fi if ! mount | grep -q ${MOUNTPOINT}; then mount ${MOUNTPOINT} || exit 1 fi mkdir -p ~/camera/${DIRNAME} && mv ${MOUNTPOINT}/dcim/???_???? ~/camera/${DIRNAME} umount /media/camera exit $?