Skip to content

Instantly share code, notes, and snippets.

@j4velin
Last active October 24, 2025 18:58
Show Gist options
  • Select an option

  • Save j4velin/a32f2fd355f5140538586f19d780d6cc to your computer and use it in GitHub Desktop.

Select an option

Save j4velin/a32f2fd355f5140538586f19d780d6cc to your computer and use it in GitHub Desktop.
Scans the given number of pages and moves the resulting pdf to the input directory for the ocr.sh script
#!/bin/bash
count=$1
resolution=150
if [ $count -gt 1 ]; then
scanimage --batch=scan_%d.tiff --batch-count=$count --format=tiff --resolution $resolution --batch-prompt
resultcode=$?
if [ $resultcode -eq 0 ]; then
tiffcp $(ls -v | grep scan_) scan.tiff
rm scan_*
fi
else
scanimage --format=tiff --resolution $resolution >scan.tiff
resultcode=$?
fi
if [ $resultcode -eq 0 ]; then
convert scan.tiff scan.pdf
rm scan.tiff
mv scan.pdf /opt/paperless/consume/scan_$(date +'%d_%m_%y_%H_%M_%S').pdf
fi
exit $resultcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment