Skip to content

Instantly share code, notes, and snippets.

@sww1235
Forked from hugorodgerbrown/md_to_rst.sh
Last active December 20, 2018 19:11
Show Gist options
  • Select an option

  • Save sww1235/8d2814290cd18b6f61a424b00fa72163 to your computer and use it in GitHub Desktop.

Select an option

Save sww1235/8d2814290cd18b6f61a424b00fa72163 to your computer and use it in GitHub Desktop.
Shell script for converting a batch of *.html files into *.md using pandoc.
#! /bin/bash
# This script was forked from https://gist.github.com/hugorodgerbrown/5317616
# and modified to convert a directory full
# of html files into md equivalents. It uses
# pandoc to do the conversion.
#
# 1. Install pandoc from http://johnmacfarlane.net/pandoc/
# 2. Copy this script into the directory containing the .html files
# 3. Ensure that the script has execute permissions
# 4. Run the script
#
# By default this will keep the original .html file
FILES="*.html"
for f in $FILES
do
# extension="${f##*.}"
filename="${f%.*}"
echo "Converting $f to $filename.md"
pandoc $f -f html -t markdown -o $filename.md
# uncomment this line to delete the source file.
# rm $f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment