Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert Mailchimp HTML Campaigns to Markdown
# This script was created to convert a directory full of Mailchimp Campaigns html files into md equivalents.
# It uses to-markdown-cli to do the conversion.
#
# 1. Install https://www.npmjs.com/package/to-markdown-cli (you must be installed node)
# 2. Copy this script into the directory containing the .html files
# 3. Modify 'sed' init and 'sed' final conditions
# - '1,/<center>/d' -> Remove all html content from init to first <center>
# - '/Ver este mensaje en el navegador/,/<\/html>/d' -> Remove all html content from "Ver este mensaje en el navegador" text to finish
# 4. Ensure that the script has execute permissions
# 5. Run the script
#
# By default this will keep the original .html file
FILES=*.html
for f in $FILES
do
# extension="${f##*.}"
filename="${f%.*}"
echo "Remove old stuff and convert $f to $filename.md"
`cat $f | sed '1,/<center>/d' | sed '/Ver este mensaje en el navegador/,/<\/html>/d' | pbcopy | html2md -o $filename.md`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment