AnsweredAssumed Answered

delete field based on CXXXX

Question asked by helenak on Jun 27, 2013
Latest reply on Jun 28, 2013 by curtvprice
System: Windows Vista and ArcGIS 9.3


I have 100 shapefiles called geocXXXX.shp (geoc0782, geoc9838, and geoc6728 etc)

In each shapefile, there is a field call CXXXX (C0782, C9838, and C6728 etc).
The field property is string, length =6.

Also, there are other fields called CXXXXMS and CXXXXMW (C0782MS and C0782MW).
The field property is long integer, length =9.

I would like to delete the fields of CXXXX, CXXXXMS, and CXXXXMW at the same time.
However, the following code did not work.
Please kindly advise how to modify it and thank you.

#Import standard library modules import arcgisscripting import os  #Create the Geoprocessor object gp = arcgisscripting.create(9.3)  #Set the input workspace #GP.workspace = sys.argv[1] #Set the workspace. gp.Workspace= "H:/temp_D/test"  #Set the output workspace #outWorkspace = sys.argv[2] #Set the workspace. List all of the feature classes in the dataset outWorkspace= "H:/temp_D"   #Get a list of the featureclasses in the input folder fcs = gp.ListFeatureClasses()  # Loop through every item in the list that was just generated for fc in fcs:       # delete the field CXXXX     gp.deletefield (fc, "C*")      gp.AddMessage(gp.GetMessages()) print gp.GetMessages()