Skip to content

Instantly share code, notes, and snippets.

@hyphop
Last active May 21, 2019 09:26
Show Gist options
  • Save hyphop/bdd8d31bf8754164b08c0e3f7d947bcc to your computer and use it in GitHub Desktop.
Save hyphop/bdd8d31bf8754164b08c0e3f7d947bcc to your computer and use it in GitHub Desktop.
simple script to automate scan process via scanimage (SANE tools) for command line usage
#!/bin/sh
## hyphop ##
#
# simple script to automate scan process via scanimage (SANE tools)
# for command line usage
#
# USAGE
# scan
#
[ "$FMT" ] || FMT=jpeg
[ "$MODE" ] || MODE=Color
[ "$RES" ] || RES=150
[ "$DIR" ] || DIR=~/Pictures/Scan
for a in "$@"; do
case "$a" in
75|150|300|600|1200)
shift
RES=$a
;;
*.jpeg|*.jpg)
shift
FMT=jpeg
OUT="$a"
DIR=
;;
*)
;;
esac
done
[ -d "$DIR" ] || mkdir -p "$DIR"
OUT="$DIR/scan_$(date +%s).$FMT"
echo "[i] scan ( $MODE/$RES ) to $DIR
> $OUT">&2
scanimage -p --mode $MODE --format $FMT --resolution $RES > "$OUT"
display "$OUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment