pdfblah.com

← All guides

Batch-edit PDFs: one recipe, a whole folder

Thousands of pages of evidence, due Friday, every page needing a sequential exhibit number across dozens of separate files. Or just "stamp DRAFT on everything in this folder". batch runs a recipe, a plain text file of steps, over every PDF you point it at.

A recipe is just the commands you already know

# discovery.recipe
bates --prefix EXH- --digits 4 --start auto
pages --drop 1
watermark --text CONFIDENTIAL
pip install pdfblah

# see the plan first: every file, every number, nothing written
pdfblah batch discovery.recipe evidence/ -o stamped/ --dry-run

# run it
pdfblah batch discovery.recipe evidence/ -o stamped/

Each file flows through the steps in order and lands in the output folder under its own name. Originals are never touched. A file that fails is reported with the step that failed, and the run continues.

The line that needs Acrobat Pro anywhere else

bates --start auto hands the numbering a counter that continues across files, in sorted name order. Two-page a.pdf gets EXH-0001 and EXH-0002; three-page b.pdf continues at EXH-0003. Dozens of scattered PDFs come out numbered like one exhibit set, and the dry run shows each file's starting number before you commit:

plan a.pdf -> stamped/a.pdf (bates from 1)
plan b.pdf -> stamped/b.pdf (bates from 3)
planned 2 file(s); next bates number would be 6

Steps a recipe can use

replace, redact, scrub, anonymize, meta, pages, rotate, crop, watermark, stamp, number, bates, protect, unlock, optimize, clean, tidy, compress, ocr. Same flags as on the command line; anything the recipe can't drive is refused up front with the line number.

Tips