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.

1 Response to Convert Trunk Notes To Plain Markdown

  1. twestley says:

    There’s a bug in setting the timestamp. I just converted about a hundred files to move them to Byword. The timestamp gets the right month and year but not the right day. It’s close enough for me.

Comments are closed.