Thanks for comments.
I corrected the code and please kindly advise any improvement to make the batch process smoothly.
(ArcGIS 9.3)
Also, a shapefile is attached for trial.
Thanks a lot.
Code
##Script Name: XY coordinates
##Description: Get longitude and latitude of point shapefile
##Created By: Elaine Kuo
##Date: 29/04/2012
#Import standard library modules
import win32com.client, sys, os
#Create the Geoprocessor object
GP = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
#Set the workspace.
GP.Workspace= "G:/temp_stage_3_centroid_of_B_NB/Sylviidae_86"
#Set the workspace. List all of the feature classes in the dataset
outWorkspace= "G:/temp_stage_3_centroid_of_B_NB/Sylviidae_86"
try:
#Get a list of the featureclasses in the input folder
fcs = GP.ListFeatureClasses()
# Loop through the above list
fcs.reset
fc = fcs.next()
while fc:
#Validate the new feature class name for the output workspace.
outFeatureClass =GP.ValidateTableName(fc,outWorkspace)
# add two new fields
GP.AddField_management(fc, "POINT_X", "DOUBLE", 4, 4)
GP.AddField_management(fc, "POINT_Y", "DOUBLE", 4, 4)
# Add X Y coordinate to the feature classes
GP.Toolbox = "Data Management"
GP.AddXY(fc)
except:
GP.AddMessage(GP.GetMessages(2))
print GP.GetMessages(2)