New Tool Radar

OCR & Text Layers

How to Batch OCR a Folder of PDFs with OCRmyPDF

Run OCRmyPDF over a whole folder of scans, then spot-check the outputs before filing them away.

Schematic illustration of batch OCR: three scans go in, three searchable PDFs come out, and the spot-check finds harvest on page 3.

Adobe’s extraction guide notes that many PDF and OCR tools support batch processing so you do not have to run recognition on each file individually, and warns to spot-check important information after processing. OCRmyPDF’s manual adds that –jobs limits how much parallel work it performs.

Use the practice file

A practice file, practice-folder. The file is fictional.

File Content
scan-01.pdf Invoice, 2 pages
scan-02.pdf Report, 6 pages, word “harvest” on page 3
scan-03.pdf Letter, 1 page

The three files are the check items: all three must come out searchable.

Batch OCR the folder

Expected result. We checked the OCRmyPDF manual and the Tesseract manual. We did not run any tool. The checks below are what to expect if the work is done correctly; run them yourself on the practice file.

1. List the folder

List the folder’s PDFs and note their page counts.

Expected result: Three files are listed: 2, 6 and 1 pages.

2. Run OCRmyPDF on each file

Run ocrmypdf on each file in turn, writing the outputs to a second folder.

Expected result: Three searchable PDFs are created in the output folder.

3. Spot-check the report

Open the output scan-02.pdf and search for “harvest”.

Expected result: 1 hit, on page 3.

4. Check the counts

Compare the output page counts with the inputs.

Expected result: The outputs hold 2, 6 and 1 pages, matching the inputs.

Verdict table

Check Expected result Pass?
List the folder Three files are listed: 2, 6 and 1 pages. —
Run OCRmyPDF on each file Three searchable PDFs are created in the output folder. —
Spot-check the report 1 hit, on page 3. —
Check the counts The outputs hold 2, 6 and 1 pages, matching the inputs. —

Related guides: How to Batch OCR a Multi-Page PDF with Consistent Settings — How to Add a Searchable Text Layer to a Scanned PDF.

Limits

  • A batch that processes every file can still fail one file silently; check the output count against the input count before filing anything away.
  • Command-line OCR rewrites the file, so always work on a copy and keep the original scan untouched.
  • UNTESTED — no OCR tool was run; all results above are expected results. The practice file is fictional.

Sources

See all