Built a 750-doctor printed directory with InDesign data merge + an automation script that does in one click what used to take 20 minutes of manual work
This is kind of use case documentation I wanted to share with fellow nerds. I used Claude Cowork extensively to build this out and develop a pretty significant workflow that crops photos, generates a CSV and allows me to use Data Merge and Scripts to automate the generation of pages and an InDesign Book to assemble a 96-page book (that's only with 30% of the data verified).
The goal is a tabbed, double-sided 8.5x11 directory pages in a leatherbound binder.
Here's the documentation:
Just wrapped the first prototype of a physician directory for a major regional health system — 700+ doctors, 18+ departments, fully data-merged in InDesign. Wanted to share the workflow because Claude and I built some automation along the way that I'm pretty proud of.
The setup:
- Source data is a master CSV of all physicians at the hospital with all their education and degrees listed, then cleaned and split by department via a Python script
- Headshots database JPGs are matched to providers by employee ID number, with fuzzy name matching as a fallback for spelling variations when the headshot database has spelling errors in the file name
- A face-crop script normalizes every headshot to an 800×1200px 2:3 frame using skin-tone detection. It handles landscape and portrait photos differently and backs up originals automatically
- Each department gets its own folder and all the photos are moved to the correct department (plus we eliminated orange backgrounds in Lightroom from an older generation of photos) and InDesign file data merge using a 3×3 grid template to layout a consistent alphabetical list of everyone and their info
The part I'm most excited about — the post-merge script:
After every merge I used to manually: find/replace pipe separators with paragraph returns, hunt down and delete empty subhead labels (Medical School / Residency / Fellowship), apply A and B parent pages for the double-sided pages and hole punches, add the document to the Book, and sync all the paragraph styles and master pages. Every. Single. Time. It was taking me like 30 minutes per department even after the merge
Now one JSX script does all of it:
- Finds and replaces
|with hard returns for multi-entry fields (over achieving doctors) - Removes empty education subheads by matching paragraph style name (not text content — way more reliable post-merge)
- Adds the document to the active Book
- Syncs the document only — not the whole book (oops learned that the hard way)
- Applies A-Parent to odd pages and B-Parent to even pages
- Detects an odd page count and automatically adds a blank B-Parent page for double-sided printing
The whole thing runs in about 3 seconds and gives you a summary dialog with counts for each step.
The paragraph-style approach for the subhead cleanup in particular was a game changer because it intelligently found empty fields (for example, most APRN physicians don't have residency or fellowship, so they just have trailing subheads that I was manually deleting). But each of those subheads has a unique paragraph style, so the script found if there was no institution under them.
This kind of puzzle is kind of insane, and I couldn't believe all the tools in InDesign were there to handle it.
Due to the nature of the client I can't really share images/examples until it's complete and published. But happy to answer any questions if you're working on something similar.