wiki/tools/inbox_watcher.page

24 lines
791 B
Plaintext
Raw Normal View History

2014-07-22 22:53:39 +00:00
---
format: markdown
toc: false
title: Pandoc Inbox Watcher Script
...
A tool for running `pandoc` when a file is saved in an inbox directory:
2014-07-22 22:51:12 +00:00
~~~ { .shell }
#!/bin/sh
INBOX=/pub/markdown/inbox
OUTBOX=../outbox/
PANDOC=/home/levi/bin/pandoc_wrapper
cd $INBOX
inotifywait -mqre close_write --format '%f' ${INBOX} | while read FILE
do
echo "Detected write on file: ${FILE}"
${PANDOC} ${FILE} ${OUTBOX}
done
~~~
2014-07-22 22:53:39 +00:00
The `pandoc_wrapper` is a script that calls pandoc with the appropriate parameters for the document formatting I want to do. It takes a source file and a destination directory as parameters; it automatically creates the destination name based on the source file name and the destination directory.
The `inotifywait` program is from the `inotify-tools` package in Ubuntu.