#!/bin/sh
#############################################################################
#
# convert.sh
#
# SCRIPT:   	lconvert_en batch use
# AUTHOR(S):	Paolo Zatelli - 2003/07/15
# PURPOSE:  	Automatically applies lconvert on a set of files
#   	    	
# COPYRIGHT:	2003 Paolo Zatelli
# LICENZE:	GPL 2.0 or (at your option) any later version
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
#############################################################################
#
# convert.sh automatically applies lconvert_en to a set of files specified as
# a pattern, such as *DTM. Converted files are named to
# original_filename.converted
#
# change OUT_FORMAT to change output file name.
# The default output format is GRASS, change OUT_FORMAT to "" for 
# Vertical Mapper
#
# Usage: sh convert.sh pattern
#

if [ ! -e ./lconvert_en ] ; then
	echo "lconvert_en not found, exiting..."
	exit
fi

if [ ! -x ./lconvert_en ] ; then
	echo "lconvert_en not executable, exiting..."
	exit
fi

#if [ $# -ne 2 ] ; then
	echo "Usage: sh convert.sh pattern"
	echo "Where pattern is the input file mask"
	echo "Ex. *DTM"
	echo  ""
	#exit
#fi

CONVERTED=0
DEST_DIR=./
OUT_FORMAT="-g"
OUT_MASK=".converted"

for ELEMENT in $@; do
	if [ ! -d "$DEST_DIR$ELEMENT" ] ; then
		echo "$ELEMENT"
		lconvert_en $OUT_FORMAT -v  $ELEMENT $ELEMENT$OUT_MASK
	fi
done

echo "$# files converted"

