-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5-Scan_flatbed_docs_to_PDF
More file actions
executable file
·34 lines (28 loc) · 1017 Bytes
/
5-Scan_flatbed_docs_to_PDF
File metadata and controls
executable file
·34 lines (28 loc) · 1017 Bytes
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
#!/bin/bash
NOW=$(date +%s)
RES=300
SRC=Flatbed #Flatbed|ADF
MODE=Color #Gray|Color|Lineart(?)
TYPE=tiff
NEWTYPE=jpeg
FINTYPE=pdf
QUALITY=35
cd $NAUTILUS_SCRIPT_CURRENT_URI
echo scan$NOW-%d.$TYPE
#scanadf --no-overwrite --mode $MODE --resolution $RES --source $SRC -o scan$NOW-%d.$TYPE
scanimage --batch-count=1 --batch=scan$NOW-%d.$TYPE --progress --format=$TYPE --mode $MODE --source $SRC --resolution $RES
for fullfilename in *.$TYPE #loop through all the files
do
origname=$(basename $fullfilename)
compressedname=$(echo $origname | sed -e "s/\.$TYPE/\.$NEWTYPE/g")
pdfname=$(echo $origname | sed -e "s/\.$TYPE/\.$FINTYPE/g")
#tiff to jpeg, trim away anything that might be missing
convert -trim -quality $QUALITY $origname $compressedname
convert $compressedname $pdfname
#if the pdf file exists get rid of the tiff file and the jpeg file
if [ -f "$compressedname" ]; then
rm $origname
rm $compressedname
echo Removed $TYPE and $NEWTYPE file
fi
done