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
- File order is numbering order, and it is sorted names: prefix files
01-,02-to control the sequence. - Deterministic by design: same folder, same recipe, same result. Rerunning after adding files renumbers everything cleanly.
- The report ends with the next free number, so tomorrow's production can start where today's stopped (
--starttakes a plain number too). - Keep recipes in the case folder and they become the documentation of what was done.