Skip to content

Instantly share code, notes, and snippets.

@jaredcrean
Forked from sunix/scantofile.sh
Created March 12, 2022 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredcrean/3e95b5027ab4b26b18e05f62164c1481 to your computer and use it in GitHub Desktop.
Save jaredcrean/3e95b5027ab4b26b18e05f62164c1481 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment