forked from arjunkc/scanner-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscantoocr-0.2.4-1.sh
More file actions
executable file
·121 lines (104 loc) · 3.04 KB
/
scantoocr-0.2.4-1.sh
File metadata and controls
executable file
·121 lines (104 loc) · 3.04 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#! /bin/bash
set +o noclobber
#
# Edited by Arjun Krishnan Apr 03 2017
#
# $1 = scanner device
# $2 = brother internal
#
# 100,200,300,400,600
#
# This is my batch scan. It scans double sided pages by default.
# query device with scanimage -h to get allowed resolutions
# Will scan from the 'brother4:net1;dev0' scanner by default.
# To do:
# ~~Apr 01 2016 To do, implement compression if possible.~~
# ~~Dec 31 2016 to do, combine even and odd files into one big pdf file~~
resolution=300
if [ -n "$1" ]; then
# if first argument is not empty
device=$1
fi
# the width is default and i wont use it. It's in mm and equal to 8.5in
width=215.88
# the height has to be set. its now 11in = 279.4 and 11.4in = 290. Setting the height higher does not work on the ADF, but does work on the flatbet
height=279.4
mode="Black & White"
epochnow=$(date '+%s')
# LOGFILE
scriptname=$(basename "$0")
# $0 refers to the script name
basedir=$(readlink -f "$0" | xargs dirname)
# change to directory of script
cd ${basedir}
echo "basedir = $basedir"
# ugly hack that makes environment variables set available
cfgfile=$(ls ../brscan-skey.config)
echo "cfgfile = $cfgfile"
if [[ -r "$cfgfile" ]]; then
echo "Found cfgfile"
source "$cfgfile"
echo "environment after processing cfgfile"
env
fi
# SAVETO DIRECTORY
if [[ -z "$SAVETO" ]]; then
SAVETO=${HOME}'/brscan/documents'
else
SAVETO=${SAVETO}'/'
fi
mkdir -p $SAVETO
if [[ -z $LOGDIR ]]; then
# if LOGDIR is not set, choose a default
mkdir -p ${HOME}/brscan
logfile=${HOME}"/brscan/$scriptname.log"
else
mkdir -p $LOGDIR
logfile=${LOGDIR}"/$scriptname.log"
fi
touch ${logfile}
# if DUPLEXTYPE is not set
if [[ -z $DUPLEXTYPE ]]; then
DUPLEXTYPE='manual'
fi
# if DUPLEXSOURCE is not set
if [[ -z $DUPLEXSOURCE ]]; then
# set DUPLEXSOURCE in the config to save unnecessary queries to the device
get_source=$(scanimage --help -d "$device" 2>&1 | sed -n 's/^\s*--source.*|\(Automatic Document Feeder[^|]*\)|.*/\1/p')
if [[ -n "$get_source" ]]; then
# if it finds an Automatic Document Feeder option, it will pick the first one.
DUPLEXSOURCE="$get_source"
fi
fi
# for debugging purposes, output arguments
echo "options after processing." >> ${logfile}
echo "$*" >> ${logfile}
# export environment to logfile
set >> ${logfile}
echo $LOGDIR >> ${logfile}
fileprefix='scantoocr'
echo "${basedir}/batchscan.py \
--outputdir ${SAVETO} \
--logdir ${LOGDIR} \
--prefix ${fileprefix} \
--timenow ${epochnow} \
--device-name ${device} \
--resolution ${resolution} \
--height $height \
--width $width \
--mode "$mode" \
--source "$DUPLEXSOURCE" \
--duplex "$DUPLEXTYPE" "
${basedir}/batchscan.py \
--outputdir ${SAVETO} \
--logdir ${LOGDIR} \
--prefix ${fileprefix} \
--timenow ${epochnow} \
--device-name ${device} \
--resolution ${resolution} \
--height $height \
--width $width \
--mode "$mode" \
--source "$DUPLEXSOURCE" \
--duplex "$DUPLEXTYPE"
#--dry-run \