Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docling-batch

A small, fault-tolerant CLI that converts a folder of PDFs to Markdown using Docling — in parallel, with graceful failure handling and free resume.

What it does

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.

Install

git clone https://github.com/elyas-karbouch/docling-batch.git
cd docling-batch
pip install -r requirements.txt

Docling downloads ~1 GB of models on first run; subsequent runs are fast.

Usage

# 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

Options

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

How failure handling works

  • 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>.md already exists in the output dir. Use --overwrite to 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 skipped and exits non-zero iff any PDF failed.

Run tests

python -m unittest test_convert.py

The end-to-end test auto-skips if reportlab isn't installed, so you can run the core tests without extra deps.

License

MIT — see LICENSE.

About

Parallel, fault-tolerant PDF->Markdown CLI using Docling

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages