#!/bin/sh

if [ $# -lt 2 ]; then
	echo "Usage: `basename $0` [-v] forcefield xyzfile..."
	exit 1
fi

if [ $1 = '-v' ]; then
	VERBOSE=1
	shift
else
	VERBOSE=
fi

FF=$1
if [ ! -f $FF ]; then
	FF=/usr/share/tinker/params/$FF.prm
	if [ ! -f $FF ]; then
		echo "can't find force field: $1"
		exit 1
	fi
fi
shift

for file in $@; do
		if [ $VERBOSE ]; then
        	printf "$file\t"
        fi
        analyze $file $FF E  | grep Total | awk '{print $5}'
done

