If you have fast flatbed scanner, you can scan 300 pages in thirty minutes. Not worth the effort to build automation. Bigger problem was to sort out all errors and missed pages afterwards. Real-time display (from Imagemaqick) solved this problem:
while true ; do
for x in *.pnm ; do
killall display
display -rotate 90 $x &
done
sleep 5
done
Nobody asked, but for the record, this is how make real one-page PDF from two-page scans. (gm = GraphicsMagick)
mkdir kaksi
rm kaksi/*
j=102
scale=600
size=500x730
yla=27
for x in *.pnm ; do
echo $x
gm convert $x -rotate 90 -crop $size+20+$yla -resize $scale -normalize kaksi/k$j.jpg
j=$((j+2))
done
j=103
for x in *.pnm ; do
echo $x
gm convert $x -rotate 90 -crop $size+530+$yla -resize $scale -normalize kaksi/k$j.jpg
j=$((j+2))
done
cd kaksi
gm convert *.jpg -format pdf TheBook.pdf
If I read this right then it means "every 5 second, open the last scanned page (and nothing else / close the previous one)". But this seems like an inefficient way to do it, opening and killing all irrelevant pages all the time. This will be more efficient and react more quickly:
lastfile=
while true; do
newestfile=$(ls *.pnm | tail -1)
if [ "$newestfile" != "$lastfile" ]; then
kill %
display -rotate 90 "$newestfile" &
lastfile=$newestfile
fi
sleep 0.3
done
Sorry but I find your answer disappointing and crossing over into offending. I spent some time first trying to understand how your code makes sense, then to write up a better solution and posted it, and you don't seem to be thankful at all and are instead dissing my effort. Sure, if it works for you, fine, I was under the impression that you didn't know better. You could have saved me time by indicating that you know your solution is hacky but you don't care.
Yes it is inefficient and weird. And thank you for saving the world. Not only Terran energy crisis, but we are also running out of useful data bits as universal entropy goes to infinity. https://en.wikipedia.org/wiki/Heat_death_of_the_universe
Thanks. Yes, sometimes communication falls short and down, and one's own state of mind is time dependent and doesn't see everything involved. I was in an eager "would like to see positive feedback" state of mind just as timonoko may have been when originally posting their solution, and then interpreted the rejection in an overly negative light. My apologies to them and for the noise.