Deleted
os.path.splitext(os.path.basename(fc))[0]
import win32com.client, sys, string, os gp = win32com.client.Dispatch("esriGeoprocessing.gpDispatch.1") gp.workspace = " ... " try: fcs = gp.ListFeatureClasses("*", "all") fc = fcs.Next() while fc: gp.AddField_management (fc, "FILENAME", "TEXT", "", "", "50") fcName = os.path.splitext(fc)[0] gp.CalculateField_management (fc, "FILENAME", fcName) fc = fcs.Next() except: print gp.GetMessages ()
import arcpy arcpy.env.workspace = " ... " try: fcs = arcpy.ListFeatureClasses("*", "all") for fc in fcs: arcpy.AddField_management(fc, "FILENAME", "TEXT", "", "", "50") fcName = os.path.splitext(fc)[0] arcpy.CalculateField_management(fc, "FILENAME", "'{0}'".format(fcName), "PYTHON_9.3") except: print arcpy.GetMessages()
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.