#!/bin/sh # written by guido socher help() { echo "run lfparser on all files in one or more directories" echo "USAGE: runlfparser [-h] [-s style] [-l lang] a_directory [a_second_directory]" exit 0 } not_a_dir() { echo "ERROR: $1 is not a directory" exit 1 } if [ -z "$1" ]; then help fi [ "$1" = "-h" ] && help while [ -n "$1" ]; do case $1 in -h) help;shift 1;; -l) opt_l="-l $2";shift 2;; -s) opt_s="-s $2";shift 2;; -*) echo "error: no such option $1. -h for help";exit 1;; *) break;; esac done [ -z "$1" ] && help for i in $*; do [ -d "$i" ] || not_a_dir $i mlist=`find $i -type f -maxdepth 1 -print | egrep "meta\..?html$"` for f in $mlist ; do if [ -f "$ff" -a ! -w "$ff" ]; then echo "ERROR: can not write to $ff" exit 2 fi ff=`echo $f | sed -e 's/\.meta//'` cmd="lfparser $opt_s $opt_l $f" echo "running $cmd > $ff ..." $cmd > $ff done done #__END__