Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shell script for converting a batch of *.md files into *.rst using pandoc.
# This script was created to convert a directory full
# of markdown files into rst equivalents. It uses
# pandoc to do the conversion.
# 1. Install pandoc from
# 2. Copy this script into the directory containing the .md files
# 3. Ensure that the script has execute permissions
# 4. Run the script
# By default this will keep the original .md file
for f in $FILES
# extension="${f##*.}"
echo "Converting $f to $filename.rst"
`pandoc $f -t rst -o $filename.rst`
# uncomment this line to delete the source file.
# rm $f
Copy link

nerdgirl commented Nov 14, 2013

Ta for letting me be super lazy. Using this to convert md for sphinx docs.

Copy link

zire commented Mar 22, 2014

Thank you! This is very helpful.

Copy link

securityfirst commented Apr 26, 2016

Thanks for this script! Very helpful 👍

Copy link

girishkdesh commented Jul 31, 2017

How to save and run script ?

Copy link

gjolleyrogers commented May 24, 2018

muchos gracias

Copy link

maazghani commented Sep 4, 2018

I love github @hugorodgerbrown for president

Copy link

rachrobts commented Sep 9, 2019

When I run this I get "open binary file does not exist". help?

Copy link

cbfranklin commented Oct 28, 2019

@rachrobts Probably spaces in your filenames.

Try adding double-quotes: `pandoc "$f" -t rst -o "docx/$filename.rst"`

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