Convert Trunk Notes To Plain Markdown

This shell script converts one or more Trunk Notes files to plain markdown. It removes the first 7 lines and touches the modification date to match the Timestamp line. It does not convert the markdown itself. For example it does not convert ~~ (strikethrough).

It assumes the input files all have the extension .markdown and writes files with extension .md, thus not destroying your original files.

#!/bin/sh

# Converts one or more Trunk Notes to plain markdown

for file in $* ; do
    basename=$(basename $file .markdown)
    timestamp=$(egrep ^Timestamp: $file | tr -d "A-Za-z: +-" | cut -c -14)
    sed -e '1,7d' < $file > $basename.md
    touch -t ${timestamp:0:12}.${timestamp:12:14} $basename.md
done
Advertisements
This entry was posted in Tools and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s