Skip to content

Create a list of subnotes with headlines

Kristoffer Bernssen edited this page Jan 12, 2019 · 3 revisions

Create a file.sh with the following content:

#!/bin/bash
#print links to subnotes with headlines
DIR=${1%.*}
DIR2=$(sed 's/.*\/[^\/]*\///g' <<<"$DIR")
for file in `find $DIR -type f -printf '%d\t%P\n' | sort -r -nk1 | cut -f2- `
do
echo $DIR2/$file | cut -f 1 -d '.' | sed 's/^/[[/; s/\//:/g; s/$/]]/g';
SUBNOTE=$DIR/$file;
cat $SUBNOTE | pcregrep -o1 -i '^\={1,6}([^=].*[^=])={1,6}$' | perl -ne 'print "*$_"'
done

Create a custom command using the following and check the "..replace current selection":

/path/to/file.sh %f

Clone this wiki locally