Skip to content

Instantly share code, notes, and snippets.

@hugorodgerbrown
Last active March 26, 2023 16:57
Show Gist options
  • Save hugorodgerbrown/5317616 to your computer and use it in GitHub Desktop.
Save hugorodgerbrown/5317616 to your computer and use it in GitHub Desktop.
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.
FILES=*.md
for f in $FILES
do
echo "Processing $f file..."
extension="${f##*.}"
filename="${f%.*}"
# take action on each file. $f store current file name
`pandoc $f -t rst -o $filename.rst`
done
@nerdgirl
Copy link

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

@zire
Copy link

zire commented Mar 22, 2014

Thank you! This is very helpful.

@securityfirst
Copy link

Thanks for this script! Very helpful 👍

@girishkdesh
Copy link

How to save and run script ?

@gjolleyrogers
Copy link

muchos gracias

@maazghani
Copy link

maazghani commented Sep 4, 2018

I love github @hugorodgerbrown for president

@rachrobts
Copy link

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

@franklin-like-the-turtle

@rachrobts Probably spaces in your filenames.

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

@vostorgmachine
Copy link

Thanks!

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