#!/bin/bash # m2w - minion send to wiki # Will publish a maximum of four .md files to .md.txt files # Meant for use wit Dokuwiki # to $M2W_DIR on $M2W_SCP_HOST year=`date +%Y` files=$(find $HOME/Journal/$year -type f -iname "*$1*\.md") if [ ! -n "$M2W_DIR" ]; then echo "Set M2W_DIR" exit 1 fi if [ ! -n "$M2W_HOST" ]; then echo "Set M2W_HOST" exit 1 fi yearmonthday=`date -I` counter=0 for file in $files; do base=`basename $file .md` # make a backup copy scp $M2W_HOST:$M2W_DIR/$base.txt $HOME/Journal/archive-$year/wiki.backup.$base.$yearmonthday.txt # deploy file as .txt scp $file $M2W_HOST:$M2W_DIR/$base.txt counter=$((counter + 1)) if [ $counter -gt 4 ]; then echo "Aborting after 4 files." echo "The following files would have been processed..." echo $files exit 1 fi done