A personal mdc CLI that wraps Microsoft's markitdown library with recursive directory conversion, mtime-based skip caching, and optional OpenAI image OCR and Whisper audio transcription.
Not Microsoft's project. This repo is Eric's thin wrapper around microsoft/markitdown, which does the actual document parsing (pulled in as the
markitdown[all]dependency). The package is published locally asmarkitdown-cli; all credit for the conversion engine goes upstream. Remote:github.com/BaruchEric/markitdown-cli.
- What:
mdc <file-or-dir>— convert documents (PDF, Office, HTML, images, audio, …) to Markdown, one file or a whole tree. - How: delegates parsing to Microsoft's
markitdown; adds the CLI ergonomics — recursive walking, mirrored output layout, mtime-based skip, per-file error aggregation, meaningful exit codes. - Optional AI:
--ocrdescribes images via OpenAIgpt-4o-mini;--audiotranscribes audio via the Whisper API (whisper-1). Plain conversions need no API key. - Stack: Python ≥ 3.11,
uv-managed, hatchling build, pytest (12 tests); deps:markitdown[all],openai,python-dotenv. - Run:
uv tool install .→mdc notes.pdformdc ~/Documents/papers -o ~/md. - A companion
markitdownClaude skill callsmdcautomatically when Claude Code hits a file it can't read directly.
mdc is a single-purpose disk utility for turning non-text files into Markdown. It hands the actual parsing to Microsoft's markitdown library and layers on what a batch CLI needs:
- Single file or recursive tree. Point it at a file or a directory; a directory is walked recursively (
rglob) and the output mirrors the source layout. - Skip-if-up-to-date. A target
.mdwhose mtime is newer than (or equal to) its source is left untouched unless--forceis passed, so re-running over a large folder only reconverts what changed. - Batch-tolerant. In tree mode a file that fails to convert is recorded as an error and the run continues; unsupported extensions are counted and skipped rather than aborting the batch.
- Optional OpenAI features.
--ocrwiresmarkitdown'sllm_clientto describe images viagpt-4o-mini;--audioroutes audio files (.mp3/.wav/.m4a/.flac) through the Whisper API instead of upstream parsing.
Output naming: a source file report.pdf becomes report.pdf.md (suffix appended, not replaced); a source directory docs/ defaults to a sibling docs.md/ tree unless -o overrides it.
Supported extensions (see formats.py): PDF; Office (.docx/.pptx/.xlsx/.xls); web (.html/.htm); data (.csv/.json/.xml); .epub/.zip/.msg; text (.txt/.rtf/.odt); images (.jpg/.jpeg/.png/.gif/.bmp/.tiff); audio (.mp3/.wav/.m4a/.flac). Match is case-insensitive; anything else is counted "unsupported" and skipped.
- Python ≥ 3.11, managed with
uv(uv.lock,.python-version). markitdown[all]≥ 0.1.5 — the conversion engine (upstream, Microsoft).openai≥ 1.40 — image description + Whisper transcription (only invoked with--ocr/--audio).python-dotenv— loadsOPENAI_API_KEYfrom a shared env file.- Build: hatchling (packages
src/markitdown_cli). Tests: pytest (dev dependency group). CI hygiene: Dependabot (.github/dependabot.yml).
Install globally as a uv tool:
uv tool install . # from inside the repo; puts `mdc` on your PATHReinstall gotcha.
uv tool install --force .can reuse cached builds and ship stale code. For a guaranteed-fresh build after local edits:uv tool uninstall markitdown-cli && uv tool install --reinstall --no-cache .
mdc notes.pdf # -> notes.pdf.md next to the source
mdc report.docx -o report.md # explicit output path
mdc ~/Documents/papers # recurse; output to sibling papers.md/
mdc ~/Documents/papers -o ~/md # recurse into a chosen output root
mdc big-folder --force # ignore the mtime skip cache, reconvert all
mdc scan.png --ocr # describe the image via gpt-4o-mini
mdc talk.mp3 --audio # transcribe via Whisper
mdc ~/docs --verbose # one log line per fileEvery run ends with a summary line: Converted N • Skipped N (up-to-date) • Unsupported N • Errors N.
--ocr and --audio require an OpenAI key. config.py looks it up in a shared dotenv file first
(ENV_PATH, currently hardcoded to /Users/ericbaruch/Arik/dev/.env) and falls back to the
process environment (OPENAI_API_KEY). If neither has it, the command exits with a clear
MissingKeyError message rather than a stack trace. Plain conversions never touch OpenAI. To adopt
the tool elsewhere, edit ENV_PATH in src/markitdown_cli/config.py or just export OPENAI_API_KEY.
0— success (or a single file skipped as up-to-date).1— tree conversion completed but one or more files errored (errors are listed).2— input path not found, or an AI feature was requested without a key.
Single Python package under src/markitdown_cli/:
__main__.py— themdcentry point (argparse). Parsesinput,-o/--output,--force,--ocr,--audio,--verbose; builds aMarkItDowninstance; dispatches to file- or tree-mode; prints the summary and returns the exit code.convert.py— the core.convert_file(single file, mtime skip, audio branch),convert_tree(recursive walk, mirrored output,ConvertSummarycounters, per-file error capture),build_markitdown(plain vs.--ocr-wired instance), andtranscribe_audio(Whisper → a# Transcript: <name>Markdown doc).config.py— env/key loading._load_env_varprefersENV_PATHthen the process env;get_openai_clientreturns anOpenAIclient or raisesMissingKeyError.formats.py— the extension allowlist:SUPPORTED_EXTENSIONS,AUDIO_EXTENSIONS,IMAGE_EXTENSIONS, and theis_supported()predicate (case-insensitive).
Tests live in tests/ (test_convert.py, test_config.py — 12 tests) with a fixtures/hello.txt
sample; run with uv run pytest. Design docs and the build plan are under docs/superpowers/.
v0.1.0, working and used day-to-day. Core conversion, recursive batching, skip caching, and the
optional OCR/audio paths are implemented and tested. Two things are intentionally personal, not
bugs: the ENV_PATH in config.py is a hardcoded absolute path to Eric's shared .env, and the
package is only installed locally (not published to PyPI). There is no LICENSE file in this repo;
the upstream microsoft/markitdown engine is MIT-licensed.