Last active
January 20, 2022 14:30
-
-
Save j4velin/1fd7fdf6c111c7c39e7ec13f68fc7678 to your computer and use it in GitHub Desktop.
Script to run ocrmypdf on new pdf files and move the ocr'ed version to the paperless input directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
workdir=/home/pi/ocr.work | |
scaninput=/home/pi/scaninput | |
outdir=/home/pi/paperless.consume | |
inotifywait -m -e close_write -e moved_to $scaninput | | |
while read -r path action file; do | |
echo "Waiting for $file..." | |
sleep 10 | |
echo "Processing $file..." | |
out="${file%%.*}.pdf" | |
ocrmypdf -l eng+deu "$scaninput/$file" "$workdir/$out" 2>&1 | tee /tmp/paperless.ocr.log | |
echo "File $file processed" | |
mv -n "$workdir/$out" "$outdir/$out" && rm "$path/$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment