on scanndistribute.sh a free scan tool chain, existent and workable

Hi there,

what is this? This is the free tool chain script I use for scanning write now on my hardware scanner. And  yes I like it? I think you might have some use as well, as it was not so easy to find another one these days. It costed me some days to gather all those command lines, bind them, test them. Right now it is in business use and you can use it, if you like. For sure one could design a proper command line user interface for it, but till then I keep glad on messing this way. Yes, and I am can say that I am in the end happy that I found a free tool chain, existent and workable. Download below.

 

# <one line to give the program’s name and a brief idea of what it does.>
# scanndistribute.sh: hardware independent config-way script for copy and paste in the console. You can use it to scan paper stacks in an adf-scanner and distribute it into documents according to your requirements. I used and tested this script with bulks of 60 papers duplex.
# Copyright (C) 2015 Tom Blecher
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/&gt;.
RANGE=1 # staple number
# usage: spapling: ie. 2 staples (RANGE=2), first 2 staples are front staples, then 2 rear reverse order, staple wise (for fitting scanners slots, about 15 leafs); after that, they are again in original order, whereas stapel 1 gets stapel 4 and vice versa
# use physical snippets 1-4 to mark each staple during the process
# usage: console 1: c&p partI first, then PartII and PartIII to console, console 2: less +F log.txt , script in Kate split view, where one window you select and c&p, on the other you manipulate code
#you think stapling is difficult? Try it on your and you will see.

#Part I inserting leafs
dup=1 # duplex=2 else 1, beidseitig
PPool=”~/Downloads”
DATE=`date +%y%m%d`
rm *doctemp* #cleaning # clean old scans here!
cd $”~/Downloads”
for (( i=1; i != $RANGE*$dup+1; i++ )) #continue by messing this
do
echo $i “. insert paper and press enter”
read;
let ii=i+10000
time scanimage -v –source ADF -b –resolution 300 -y 297 -x 210 –format=tiff –batch=doctemp${ii:2:3}-p%03d.tiff –batch-start=1 >> log.txt 2>&1
#doctemp2-p001.tiff #-y 355.6 -x 215.9: big black bar below
#scanimage –help|grep eso
ls -rtl|tail >> log.txt 2>&1
done

# as non interactive as possible from here on, Part II
for (( i=1; i < $RANGE*$dup+1; i++ ))
do
echo $i >> log.txt 2>&1
let ii=i+10000
time convert doctemp${ii:2:3}-p*.tiff doctempconv${ii:2:3}.pdf >> log.txt 2>&1
# bug?
ls -rtl|tail >> log.txt 2>&1
done

for (( i=1; i < $RANGE+1; i++ ))
do
echo $i
let ii=i+10000
mv doctempconv${ii:2:3}.pdf doctempf${ii:2:3}.pdf
done
pdftk doctempf*.pdf cat output doctempgetherf.pdf

for (( i=$RANGE+1; i < $RANGE*$dup+1; i++ ))
do
echo $i
let ii=i+10000
mv doctempconv${ii:2:3}.pdf doctempr${ii:2:3}.pdf
done
pdftk doctempr*.pdf cat output doctempgetherr.pdf

pdftk A=doctempgetherf.pdf B=doctempgetherr.pdf shuffle A Bend-1 output doctempbundle.pdf || mv doctempgetherf.pdf doctempbundle.pdf
# or if non duplex
ls -rtl|tail >> log.txt 2>&1
pdfinfo doctempbundle.pdf |grep Pages >> log.txt 2>&1
#sandwich

time /opt/OCRmyPDF-2.2-stable/OCRmyPDF.sh -f -l deu ./doctempbundle.pdf doctempbundlesandw1.pdf >> log.txt 2>&1
pdftotext doctempbundlesandw1.pdf – |tail -5 >> log.txt 2>&1
ls -l doctempbundlesandw1.pdf >> log.txt 2>&1

#Part III
#distribute
xpdf doctempbundlesandw1.pdf
#uff wie got some Problems big black bars below, this:
#pdfcrop –margins ‘0 0 0 -189’ –clip doctempbundlesandw1.pdf doctempoutput.pdf
#mv doctempoutput.pdf doctempbundlesandw1.pdf

#extract 1 leave copy

#extracts1
#Pstore=”./”
Pstore=””
#Nstore=$DATE”noticexydoctemp.pdf”
Nstore=$DATE””
let Nstart=1
let Nend=10

pdftk A=doctempbundlesandw1.pdf cat A$Nstart-$Nend output $Pstore$Nstore
pdfinfo $Pstore$Nstore |grep Pages >> log.txt 2>&1
pdftotext $Pstore$Nstore – |head -125|tail >> log.txt 2>&1
ls -l $Pstore$Nstore >> log.txt 2>&1
#k
#extracts1 end

#extracts2
#Pstore=”./”
Pstore=””
#Nstore=$DATE”noticexydoctemp.pdf”
Nstore=$DATE””
let Nstart=19
let Nend=28

pdftk A=doctempbundlesandw1.pdf cat A$Nstart-$Nend output $Pstore$Nstore
pdfinfo $Pstore$Nstore |grep Pages >> log.txt 2>&1
pdftotext $Pstore$Nstore – |head -125|tail >> log.txt 2>&1
ls -l $Pstore$Nstore >> log.txt 2>&1
#k
#extracts2 end

#extracts3
#Pstore=”./”
Pstore=””
#Nstore=$DATE”noticexydoctemp.pdf”
Nstore=$DATE””
let Nstart=49
let Nend=54

pdftk A=doctempbundlesandw1.pdf cat A$Nstart-$Nend output $Pstore$Nstore
pdfinfo $Pstore$Nstore |grep Pages >> log.txt 2>&1
pdftotext $Pstore$Nstore – |head -125|tail >> log.txt 2>&1
ls -l $Pstore$Nstore >> log.txt 2>&1
#lp -o ColorModel=KGray -o fit-to-page -o outputorder=reverse $Pstore$Nstore
#k
#extracts3 end

#extracts4
#Pstore=”./”
Pstore=””
#Nstore=$DATE”noticexydoctemp.pdf”
Nstore=$DATE””
let Nstart=13
let Nend=15

pdftk A=doctempbundlesandw1.pdf cat A$Nstart-$Nend output $Pstore$Nstore
pdfinfo $Pstore$Nstore |grep Pages >> log.txt 2>&1
pdftotext $Pstore$Nstore – |head -125|tail >> log.txt 2>&1
ls -l $Pstore$Nstore >> log.txt 2>&1
#k
#extracts4 end

#extracts5
#Pstore=”./”
mkdir “”
Pstore1=””

Pstore=””
#Nstore=$DATE”noticexydoctemp.pdf”
Nstore=”14.pdf”
Nstore1=$DATE”16.pdf”

let Nstart=1
let Nend=2
# C=pathtoappliedpdf.pdf
# pdftk B=$B cat B11-end output “$C”
# xpdf “$C” #extracting 3 from end
pdfinfo $Pstore$Nstore |grep Pages >> log.txt 2>&1

pdftk A=doctempbundlesandw1.pdf B=$Pstore$Nstore cat B A$Nstart-$Nend output $Pstore$Nstore”_”
pdfinfo $Pstore$Nstore”_” |grep Pages >> log.txt 2>&1
pdftotext $Pstore$Nstore”_” – |head -125|tail >> log.txt 2>&1
ls -l $Pstore$Nstore”_” >> log.txt 2>&1
mv $Pstore$Nstore”_” $Pstore$Nstore

cp doctempbundlesandw1.pdf $Pstore1$Nstore1
ls -l $Pstore1$Nstore1 >> log.txt 2>&1
#k
#extracts5 end

#extracts6
#attach from 2 sources and drop a copy elsewhere
#Pstore=”./”
Pstore=””
#Nstore=$DATE”noticexydoctemp.pdf”
Nstore=””
Nstore_s1=””
Nstore_s2=”pdf”
Pstore1=”…/sonstigehandouts/”
Nstore1=””

let Nstart_s1=1
pdfinfo $Pstore$Nstore |grep Pages >> log.txt 2>&1

#attach
pdftk A=$Pstore$Nstore_s1 B=$Pstore$Nstore_s2 C=$Pstore$Nstore cat C A$Nstart B$Nstart output $Pstore$Nstore”_”
pdfinfo $Pstore$Nstore”_” |grep Pages >> log.txt 2>&1
pdftotext $Pstore$Nstore”_” – |head -125|tail >> log.txt 2>&1
ls -l $Pstore$Nstore”_” >> log.txt 2>&1
mv $Pstore$Nstore”_” $Pstore$Nstore
ls -l $Pstore$Nstore >> log.txt 2>&1
# uff k
#drop another copy
pdftk A=$Pstore$Nstore_s1 B=$Pstore$Nstore_s2 cat A$Nstart B$Nstart output $Pstore1$Nstore1

pdfinfo $Pstore1$Nstore1 |grep Pages >> log.txt 2>&1
pdftotext $Pstore1$Nstore1 – |head -125|tail >> log.txt 2>&1
ls -l $Pstore1$Nstore1 >> log.txt 2>&1

#k 6
#extracts6 end
rm *doctemp[!0-9]*
rm *doctemp* #cleaning

kate_multiscreen_demo1uConsole

#https://softwareforhartz4entertainer.files.wordpress.com/2015/08/publishedscanndistribute-tar-gz-openastarnotas1.pdf

#here you got the package of it

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s