Hi,
I have a Kornshell Script which I want to execute on a directory with a series of files;
eg.
XXXX.shp
XXXX_MSLINK.shp
YYYY.shp
YYYY_MSLINK.shp
ZZZZ.shp
ZZZZ_MSLINK.shp
ect.
I want to add a condition to my for loop. I only want my for loop to run when I have files which can be translated against each other. For example,
in my inputdirectory I only want my loop to run when I have files XXXX.shp and XXXX_MSLINK.shp ect. in the inputdirectory.
I DO NOT want my for loop to run when I'm missing files. For example,
in my input directory I DO NOT want my loop to run when I have XXXX.shp and no corresponding XXXX_mslink.shp. Or XXXX_mslink.shp and NO XXXX.shp. Instead I could have a message box pop up with a message to the user with the option to terminate the program.
My Code:
# enter do loop and translate each .shp file in the InputDirectory
for file in $InputDirectory/*.shp
do
base=`basename $file.shp`
if [ -e ${base}_mslink.shp ]
then
# strip off path
fname=${file##*/}
# strip off extention
fname=${fname%.*}
print |tee -a -i $WorkingDirectory/change.txt
print "translating $fname.shp from shape to shape" |tee -a -i $WorkingDirectory/change.txt
print "======================" |teje -a -i $WorkingDirectory/change.txt
# *executes desired translation
fi
done
Any help would be greatly appreciated as this code doesnt seem to be working.
Thanks,
Beery