#!/bin/bash # -s makes the doc a standalone document instead of a snippet for doc in org/*.org do # this will return a list of files like 'org/somefile.org' # to only get the filename we could enter the folder or # use sed to replace it by regex or use basename. filename=$(basename $doc) # we want to get rid of .org nosuffix=$(echo "$filename"|sed -E "s/\.org$//") # this looks terrible, i know. -E makes it POSIX compatible # $ locks it to the end, ^ to the beginning # * . ( ) { } [ ] need to be escaped with \ htmlfile="html/$nosuffix.html" echo "$doc > $htmlfile" pandoc -s --toc $doc -o - | \ sed -E "s/(<\/title>)/\1\n /" | \ sed -E "s/(
)/\1\n