# HG changeset patch # User casties # Date 1151566732 -7200 # Node ID a175b62e75849f48c03eb8b6f75888ee3f00299d # Parent 2afcb4ff750e6ad58a3c46d7077cd4ba98445d59 first working version diff -r 2afcb4ff750e -r a175b62e7584 changemany.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/changemany.sh Thu Jun 29 09:38:52 2006 +0200 @@ -0,0 +1,53 @@ +#!/bin/bash + +VERSION="changemany V0.1 (29.6.2006 ROC)" + +#set -x + +if [ -z "$1$2" ] +then + echo $VERSION + echo "use: $0 dirlist [params...]" + echo " Changes the document directories given in the file dirlist." + echo " The list has the full pathname first and then one column per parameter, separated with spaces." + exit 1 +fi + +DIRLIST="$1" +PARAM1="$2" +PARAM2="$3" +PARAM3="$4" + +if [ ! -f $DIRLIST ] +then + echo "ERROR: directory list file $DIRLIST not found!" + exit 1 +fi + +CNT=0 + +# read directories and options from DIRLIST +while read DIR OPT1 OPT2 OPT3 +do + CNT=$(( $CNT + 1 )) + if [ -d "$DIR" ] + then + echo "changing document $CNT: $DIR..." + if /usr/local/mpiwg/archive/changemeta "${PARAM1:+$PARAM1=$OPT1}" "${PARAM2:+$PARAM2=$OPT2}" "${PARAM3:+$PARAM3=$OPT3}" "$DIR" + then + echo " OK" + else + echo "FAILED!" + # abort? + fi + else + echo "$CNT ERROR: document directory $DIR not found!" + fi +done < $DIRLIST + +if [ $CNT = 0 ] +then + echo "ERROR: the list file $DIRLIST seems to be empty!" +else + echo "Processed $CNT documents!" +fi