Skip to content

Instantly share code, notes, and snippets.

@sunix
Created August 5, 2012 08:49
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save sunix/3263040 to your computer and use it in GitHub Desktop.
Save sunix/3263040 to your computer and use it in GitHub Desktop.
My Brother brscan scanner S-KEY tool scan to file script. Scan from ADF, convert to PDF and merge PDFs files into a single one.
#! /bin/sh
set +o noclobber
#
# $1 = scanner device
# $2 = friendly name
#
#
# 100,200,300,400,600
#
resolution=200
device=$1
BASE=~/brscan
mkdir -p $BASE
if [ "`which usleep 2>/dev/null `" != '' ];then
usleep 10000
else
sleep 0.01
fi
output_tmp=$BASE/$(date +"%Y-%m-%d_%Hh%M")
echo "scan from $2($device)"
scanimage --device-name "$device" --resolution $resolution --batch="$output_tmp"_%04d.tiff --format=tiff -x 210 -y 297
for tifffile in $(ls "$output_tmp"*)
do
tiffcp -c lzw "$tifffile" "$tifffile".lzw.tiff
tiff2pdf "$tifffile".lzw.tiff > "$tifffile".pdf
rm -f "$tifffile"
rm -f "$tifffile".lzw.tiff
done
pdftk $output_tmp*.pdf cat output "$output_tmp".pdf
@calvinrw
Copy link

This just saved me several hours of screwing around with the original scantofile.sh to get it to generate PDF files. Thank you for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment