A small, fault-tolerant CLI that converts a folder of PDFs to Markdown using Docling — in parallel, with graceful failure handling and free resume.
Point it at a folder of PDFs, get a folder of .md files. One bad PDF doesn't stop the batch. Workers run in separate processes so a crash or OOM in one file is isolated. Rerun the command and it skips anything already converted.
git clone https://github.com/elyas-karbouch/docling-batch.git
cd docling-batch
pip install -r requirements.txtDocling downloads ~1 GB of models on first run; subsequent runs are fast.
# Convert every PDF in ./my_pdfs to Markdown in ./out using all CPU cores
python convert.py ./my_pdfs
# Custom output directory and worker count
python convert.py ./my_pdfs -o ./markdown -w 8
# Walk subdirectories and redo everything
python convert.py ./my_pdfs --recursive --overwrite| Flag | Default | Purpose |
|---|---|---|
input_dir |
(required) | Folder containing PDFs |
-o, --output |
./out |
Where .md files are written |
-w, --workers |
CPU count | Parallel worker processes |
--overwrite |
off | Reprocess PDFs whose .md already exists |
--recursive |
off | Recurse into subfolders |
- Per-file isolation. Each PDF is converted inside a worker process. A segfault, OOM, or unhandled exception in one file cannot kill the pool.
- Never raises. Worker returns
("fail", error)instead of propagating — the batch always completes. - Resume for free. Reruns skip any PDF whose
<stem>.mdalready exists in the output dir. Use--overwriteto redo. - Failure log. When the run ends, failures are written to
<output>/failures.log, one line per PDF:<path>\t<error>. - Summary. The run ends with
N ok / M failed / K skippedand exits non-zero iff any PDF failed.
python -m unittest test_convert.pyThe end-to-end test auto-skips if reportlab isn't installed, so you can run the core tests without extra deps.
MIT — see LICENSE.