aboutsummaryrefslogtreecommitdiff
path: root/scan.sh
blob: ecb505c79dabb335991c0ce2efbbcc04ea7dd756 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash

function scanpage {
  echo -n insert $1 and press return
  read
  scanimage \
    -d 'brother5:bus2;dev2' \
    --AutoDocumentSize=yes \
    --format=pdf \
    --resolution 300 \
    --AutoDeskew=yes \
    -o $1 2>/dev/null
}

if [[ -z $1 ]] ; then
  echo -n 'prefix ?'
  read pref
  [[ -z $pref ]] && exit
else
  pref=$1
  shift
fi

if [[ -z $1 ]] ; then
  while true ; do
    echo -n 'document#(s) ?'
    read n
    [[ -z $n ]] && exit
    for j in $n ; do
      scanpage ${pref}-$j.pdf
    done
  done
else
  for j in $* ; do
    scanpage ${pref}-$j.pdf
  done
fi