Linux Blog

Automated Scanning with the Shell – UPDATE

Filed under: Shell Script Sundays — TheLinuxBlog.com at 10:00 am on Sunday, December 18, 2011

I wrote a little script a while back that would help to automate scanning from the shell.  Mark posted some suggestions that I’ll be implementing in this post.

The first suggestion was to make the script work all the time, basically only stopping when exit, or quit was typed. Firstly, I needed to modify the if statement. While I was at it, I changed the loop too. There was no need to stop at 1000 if I was making the file by timestamp and waiting for “exit” in the shell.

Second suggestion was to save it into a time stamped file.

That is pretty easy to implement. Using the date tool, you can format a string to your liking, use date –help to find the format. I used “date +%F_%T ” for this example. Shows YYYY-MM-DD_HH:MM:SS

Setting the variable DATE=`date +%F_%T` and piping the output of scanimage to the new file instead of $i;

scanimage --resolution 400 > $DATE.pnm;

I don’t have an automatic document feeder so I can’t do anything with ADF at this time, but I do have a scanner on my wishlist, I have a ton of documents I’d like to get rid of the physical copies, and to be honest, this script isn’t going to be quick enough.

Here is the new scanimagedate script and here is the source of the new file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
 
#while reading input line
while read inputline; do
 
# Make sure its not exit typed
if [ "$inputline" != "exit" ]; then
 
# Format Date
DATE=`date +%F_%T`
echo Scanning $DATE;
 
#Process Scanned Image
scanimage --resolution 400 > $DATE.pnm;
echo Saved: $DATE.pnm
 
# exit, if it was typed
else
exit
fi
done;

Man Pages for commands in this post »

scanimage
xsane

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>