Use
Batch conversion with MarkItDown
The command converts one file per run, and each run spends about a second starting Python. For a folder, use one Python process that reuses a single converter: 400 files took 27 seconds that way and 402 seconds as one command per file in our test.
Short answer
In Python, create one MarkItDown(), loop over the files, and catch errors per file:
from pathlib import Path
from markitdown import MarkItDown
md = MarkItDown() # one converter for the whole run
out_dir = Path("converted"); out_dir.mkdir(exist_ok=True)
ok, failed = 0, []
for path in sorted(Path("samples").glob("*")):
if path.suffix.lower() not in {".docx", ".xlsx", ".pptx", ".pdf", ".csv", ".html"}:
continue # skip types we did not ask for
try:
text = md.convert(path).markdown
(out_dir / (path.name + ".md")).write_text(text, encoding="utf-8")
ok += 1
except Exception as e: # one bad file must not stop the run
failed.append((path.name, type(e).__name__))
print(f"converted {ok}, failed {len(failed)}")
for name, err in failed: print(" failed:", name, err)converted 46, failed 1
failed: pdf-encrypted.pdf FileConversionException Tested with markitdown 0.1.9 · Python Linux lab, 4 CPU cores, Python 3.13, markitdown 0.1.9; 47 sample files for the folder run, 400 copies for the timings (T15, T09) · 2026-11-16 · evidence: batch-modes.csv, bash-loop.log
A shell loop: simple, slow
for f in *.docx *.xlsx *.pptx; do markitdown "$f" -o "${f%.*}.md"; doneThis works, but it starts Python for every file. We timed 400 files this way at about 1 file a second.
One process, one converter
The Python loop above converted 46 of the 47 files in our sample folder and reported the one that failed, an encrypted PDF, instead of stopping. Reuse one converter: creating it loads the file-type model, which is most of the cost of a small file (speed page).
In parallel
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
from markitdown import MarkItDown
def convert_chunk(paths):
md = MarkItDown() # one converter per worker process
return [(p, len(md.convert(p).markdown)) for p in paths]
if __name__ == "__main__": # required for process pools on Windows and macOS
files = [str(p) for p in sorted(Path("samples").glob("*.docx"))] + [str(p) for p in sorted(Path("samples").glob("*.xlsx"))]
chunks = [files[i::2] for i in range(2)] # two workers
with ProcessPoolExecutor(2) as pool:
for chunk in pool.map(convert_chunk, chunks):
for name, n in chunk: print(f"{Path(name).name:<28} {n:>6} characters")docx-bullets.docx 48 characters
docx-image-alt.docx 61 characters
docx-merged-cells.docx 121 characters
docx-nested-lists.docx 112 characters
docx-table-header.docx 97 characters
docx-table-pipe.docx 61 characters
report.docx 838 characters
xlsx-blank-rows-cols.xlsx 111 characters
xlsx-formulas-recalculated.xlsx 72 characters
xlsx-header-row3-merged-hidden.xlsx 357 characters
xlsx-int-blank.xlsx 73 characters
xlsx-number-formats.xlsx 401 characters
xlsx-sheets.xlsx 118 characters
docx-custom-styles.docx 41 characters
docx-images-no-alt.docx 103 characters
docx-nested-bullets.docx 54 characters
docx-pipe-newline-table.docx 106 characters
docx-table-no-header.docx 108 characters
docx-title-subtitle.docx 64 characters
workbook.xlsx 526 characters
xlsx-empty-hidden.xlsx 115 characters
xlsx-formulas-uncached.xlsx 77 characters
xlsx-header-row3.xlsx 132 characters
xlsx-merged-header.xlsx 143 characters
xlsx-pipe-newline.xlsx 86 characters | Mode | Seconds | Files per second |
|---|---|---|
| command line, one process per file (40 files, scaled to 400) | 402.3 | 1.0 |
| one Python process, one MarkItDown reused | 27.3 | 14.6 |
| process pool, 2 workers, one MarkItDown each | 23.7 | 16.9 |
| process pool, 4 workers, one MarkItDown each | 23.1 | 17.3 |
| thread pool, 4 threads, one shared MarkItDown (empty results: 0) | 30.1 | 13.3 |
Workers helped only a little on small files (17 against 15 files a second), because each worker also starts up. A thread pool sharing one converter worked without errors but was slower. Parallelism pays off more with large files; we did not measure that.
Failures and what to do about them
A failed file raises an exception; catch it per file (the first snippet does). Scanned files return an empty result with no exception, so check the output length (OCR). Missing extras raise MissingDependencyException (missing dependency).
Not tested
PowerShell and Command Prompt loops, converting from a queue, and progress reporting.