25 lines
493 B
Bash
25 lines
493 B
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
|
||
|
|
# Simple script to OCR multiple PDFs using ocrmypdf.
|
||
|
|
# Usage: ocrpdf.sh input.pdf
|
||
|
|
|
||
|
|
if [ $# -eq 0 ]; then
|
||
|
|
echo "Usage: $(basename "$0") input.pdf"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
for f in "$@"; do
|
||
|
|
# Make sure it's a PDF
|
||
|
|
if [[ "$f" == *.pdf ]]; then
|
||
|
|
dir=$(dirname "$f")
|
||
|
|
base=$(basename "$f" .pdf)
|
||
|
|
out="${dir}/${base}-ocr.pdf"
|
||
|
|
|
||
|
|
echo "Processing $f -> $out"
|
||
|
|
ocrmypdf --redo-ocr "$f" "$out"
|
||
|
|
echo "Created: $out"
|
||
|
|
else
|
||
|
|
echo "Skipping non-PDF file: $f"
|
||
|
|
fi
|
||
|
|
done
|