Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save petergi/a9c4648b641440c00604a485bff6d0b1 to your computer and use it in GitHub Desktop.
Save petergi/a9c4648b641440c00604a485bff6d0b1 to your computer and use it in GitHub Desktop.
This command will convert each .docx file in the directory to a Markdown file with ATX-style headers. If you prefer Setext-style headers, you can replace atx with setext.
# 1 - Export to Word Document: First, export your OneNote pages to a .docx (Word) format using the OneNote export feature from the File menu.
# 2 - Install Pandoc: Install Pandoc on your Mac (https://gist.github.com/petergi/dcfe4279bb9c586463d0c4936a0738df#file-install-pandoc-on-macos-sh).
# 3 - Convert to Markdown: Use the terminal to navigate to the directory where your .docx files are saved.
# Run the following command to convert the .docx files to Markdown:
for file in *.docx; do
pandoc -f docx -t markdown_strict -i "$file" -o "${file%.docx}.md" --wrap=none --markdown-headings=atx
done
@petergi
Copy link
Author

petergi commented Jun 26, 2025

If you need to install Pandoc: Another Gist

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