Skip to content

Instantly share code, notes, and snippets.

@ngoffee
Created November 1, 2012 01:11
Show Gist options
  • Save ngoffee/3990991 to your computer and use it in GitHub Desktop.
Save ngoffee/3990991 to your computer and use it in GitHub Desktop.
Convert a directory of Notational Velocity notes to a single Emacs org-mode file
#!/bin/sh
# Convert a directory of Notational Velocity notes to a single file of
# Emacs org-mode notes. Must be run from within the directory to be
# converted. Each entry in the resulting org file will be a 2nd-level
# entry ("** ...") whose title is derived from the filename and whose
# body contains the file contents. Output is written to stdout. '*' at
# the beginning of a line will be converted to '-' to avoid being
# confused with an org-mode headline.
echo "#+STARTUP: content indent hidestars"
echo
for filename in *.txt; do
title=$(echo "${filename%.txt}" | sed \
-e 's,-:,://,g' \
-e 's,:,/,g' \
-e 's,-,:,g')
echo
echo "** ${title}"
echo
sed -E 's,^[*],-,' "${filename}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment