I'm a novice at programming and need some help with a kornshell script I've been writting.
I have an inputdirectory with all my .shp files. In my input directory the shapefiles are named XXXX_original.shp, XXXX_UPDATE.shp ect.
In my .ksh script I have created a for loop which loops through all the files in the inputdirectory preforming a translation. Here is my code for my for loop.
for file in $InputDirectory/*.shp
do
*runs translation
done
This works fine, but 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 input directory I only want my loop to run when I have files XXXX_original.shp and XXXX_Update.shp ect. in the input directory.
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_original.shp and no corresponding XXXX_Update.shp. Or XXXX_Update.shp and NO XXXX_original.shp. Instead I could have a message box pop up with a message to the user.
I also have a do loop which will preform a transformation on each file in the shp_mslinks directory, my loop;
# enter do loop and translate each shp file in the InputDirectory
for file in $InputDirectory/.shp
do
# 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
# run translation program
done
The problem is is only runs the transformation on the _original.shp files in the shp_mslinks directory and I want it to run on both the _original.shp and _UPDATE.shp