New Tool Radar

AI PDF

How to Find Duplicate Scans in a PDF Library by Comparing OCR Text

Find duplicate scans in a PDF library by comparing their OCR text so the library holds one copy of each document.

Schematic illustration of library deduplication: collect the OCR text, compare the texts, and confirm each duplicate pair.

A library built from years of scanning holds the same document twice under different names, and the duplicates waste space and confuse searches. Comparing file names misses them; comparing the OCR text finds them. This guide checks a small library that way.

Prerequisites

A folder of scanned PDFs with OCR text, for example sidecar files from OCRmyPDF. Work on copies until the duplicates are confirmed.

Steps

1. Collect the OCR text for every file

Gather the sidecar text file for each PDF in the library. Expected result: twelve sidecar files are collected, one per PDF.

2. Compare the texts pairwise

Compare the texts and flag the pairs that match closely. Expected result: two pairs match, out of twelve files.

3. Confirm each pair by opening both files

Open both files in each flagged pair and compare the first pages. Expected result: both pairs are true duplicates.

4. Record which copy to keep

Record which copy of each pair to keep and which to delete. Expected result: a note that names the two files to keep and the two to delete.

Practice check: fictional library of twelve scanned PDFs, two duplicates

The table below is fictional practice material. It lists the two duplicate pairs and the copy to keep.

Pair Keep
scan001.pdf and scan007.pdf scan001.pdf
scan003.pdf and scan011.pdf scan003.pdf

Expected result. two duplicate pairs are found in twelve files, and the earlier copy is kept in each pair.

Limits

  • OCR text comparison can flag two different documents that share boilerplate as duplicates, so open both files before deleting anything.
  • UNTESTED – no OCR tool or AI tool was run; all results above are expected results. The practice file is fictional.

Sources

  • OCRmyPDF Cookbook – –sidecar writes OCR text to a companion file; –output-type pdfa/pdf picks the output; –optimize shrinks the file; –mode strip removes the text layer. Checked 2026-11-29.
  • Tesseract OCR Documentation, output formats – Tesseract supports plain text, searchable PDF, hOCR, TSV, ALTO and PAGE output; –psm sets the page segmentation mode. Checked 2026-11-29.
See all