Skip to content

Instantly share code, notes, and snippets.

@philpicton
Forked from dropletmedia/docx-to-md.sh
Created November 27, 2025 16:23
Show Gist options
  • Select an option

  • Save philpicton/3e7c98d182436062192205064e67811d to your computer and use it in GitHub Desktop.

Select an option

Save philpicton/3e7c98d182436062192205064e67811d to your computer and use it in GitHub Desktop.
Convert docx to markdown
#!/bin/bash
# a script to convert docx to markdown and extract images into subfolder
# requirements: pandoc
#
if [ -z "$1" ]; then
echo "Usage:"
echo ""
echo " docx-to-md.sh [filename-no-extension]"
exit 13
fi
if [ ! -f "$1.docx" ]; then
echo "FATAL missing file '$1.docx'"
exit 11
fi
mkdir -p "$1"
cd "$1"
pandoc -f docx -t markdown --extract-media="." -o "$1.md" "../$1.docx"
@philpicton
Copy link
Author

  • install pandoc
  • remember to mark this as executable.
  • docx-to-md.sh [filename no extension]
  • will output the .md, and put any images in a folder at same location with same name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment