A powerful batch document conversion tool that transforms PDF, Word, Excel, PPT, and more into clean, structured Markdown — with intelligent image and table handling.
- ✅ Batch Conversion – Convert PDF, Word, Excel, PPT, and more to clean Markdown
- ✅ Batch Chunking – Process Markdown files into Dify-ready formats
- 🔄 Concurrent Execution – Multi-threaded for faster throughput
- 🔍 Auto Discovery – Recursively scan directories for supported files
- 🖼️ Smart Image Handling – Extract images as files + embed Base64 fallback
- 📊 Table Optimization – Preserve layout with Markdown-compatible formatting
- 📈 Conversion Report – Detailed stats: success/failure, timing, image counts
- 🛡️ Robust Error Recovery – Gracefully handle corrupt or unsupported files
- ⚙️ Fully Configurable – Customize workers, output path, and Docling service URL
| Format | Extensions |
|---|---|
.pdf |
|
| Microsoft Word | .docx, .doc |
| Excel | .xlsx, .xls |
| PowerPoint | .pptx |
| Plain Text | .txt |
| Web Documents | .html, .xml |
| Format | Extensions |
|---|---|
| Markdown | .md |
- Python 3.9+
- Running Docling-serve instance (local or remote)
git clone https://github.com/ethanrise/docling-batch-processor.git
cd docling-batch-processorpip install -r requirements.txtdocker run -p 9969:5001 quay.io/docling-project/docling-serve:latestCreate docker-compose.yml:
version: '3.8'
services:
docling-serve:
image: quay.io/docling-project/docling-serve:latest
ports:
- "9969:5001"
volumes:
- ./uploads:/app/uploadsThen run:
docker-compose up -d💡 Ensure port
9969is accessible and not blocked by firewall.
Convert various document formats to Markdown:
# Convert specific files
python batch_convert.py file1.pdf file2.docx
# Convert all supported files in a directory
python batch_convert.py -d /path/to/documents
# Specify custom output directory
python batch_convert.py file1.pdf -o ./results
# Increase concurrency & use custom service URL
python batch_convert.py -d ./docs -o ./results --workers 5 --url http://remote-server:9969/v1/convert/fileProcess Markdown files into Dify-ready format:
# Process all Markdown files in a directory
python batch_chunk.py -d /path/to/markdown/files
# Specify custom output directory
python batch_chunk.py -d ./markdown_files -o ./dify_ready
# Use custom API endpoint
python batch_chunk.py -d ./docs --url http://remote-server:9969/v1/chunk/hybrid/source| Argument / Flag | Description | Default |
|---|---|---|
input_files |
List of input file paths | (required if -d not used) |
-d, --directory |
Input directory to scan recursively | — |
-o, --output |
Output directory | Parent of first input file |
--workers |
Number of concurrent workers | 3 |
--url |
Docling service endpoint | http://localhost:9969/v1/convert/file |
| Argument / Flag | Description | Default |
|---|---|---|
-d, --directory |
Input directory containing Markdown files | (required) |
-o, --output |
Output directory | {input_dir}/../dify_ready |
--url |
Document chunking service endpoint | http://127.0.0.1:9969/v1/chunk/hybrid/source |
Each converted file generates:
output/
├── document.md # Clean Markdown output
├── document_images/ # Extracted images (PNG/JPG)
│ ├── image_20260129_001.png
│ └── image_20260129_002.jpg
└── conversion_report.txt # Summary report
Each Markdown file generates a processed version:
output/
├── document_processed.txt # Clean, chunked content ready for Dify
└── processing_report.txt # Summary report
The conversion_report.txt includes:
- Total files processed, success/failure counts
- Per-file processing time
- Number of extracted images
- Error details for failed conversions
Example snippet:
✅ Successfully converted: 12 files
❌ Failed: 2 files
⏱️ Total time: 42.3s
📸 Total images extracted: 37
docling-batch-processor/
├── batch_convert.py # CLI entry point for conversion
├── batch_chunk.py # CLI entry point for chunking
├── core/
│ ├── batch_converter.py # Orchestrates the full pipeline
│ ├── docling_client.py # HTTP client for Docling API
│ ├── file_validator.py # Validates input files
│ ├── image_processor.py # Handles image extraction & saving
│ ├── table_processor.py # Optimizes table formatting
│ └── output_manager.py # Manages output files & report
└── requirements.txt
batch_converter: Main controller that coordinates all componentsdocling_client: Wraps API calls to Docling-serveimage_processor/table_processor: Post-process conversion resultsoutput_manager: Handles file I/O and report generationmarkdown_processor: Main controller for chunking pipeline
- ✅ Is Docling-serve running? Check with
docker ps - ✅ Is the URL correct? Default:
http://localhost:9969/v1/convert/file - ✅ Is the port open? Try
curl http://localhost:9969/health
- Ensure files aren’t corrupted
- Extension must match actual format (e.g., don’t rename
.zipto.docx)
- Reduce concurrency( batch_convert.py):
--workers 1 - Process smaller batches
Contributions are welcome! Please:
- Open an issue to discuss feature requests or bugs
- Fork the repo and submit a PR with clear commit messages
- Add tests if applicable
See CONTRIBUTING.md (optional but recommended).
- Email: thanrise.ai@gmail.com
- GitHub: @ethanrise
- LinkedIn: linkedin.com/in/ethanrise
💬 Feel free to reach out for collaboration or feedback!