Populate attribute field within geodatabase using feature class name

Discussion created by myriadbanshee on Mar 22, 2012
Latest reply on Mar 27, 2012 by myriadbanshee
Do you have anywhere I can start my search on finding a python script that autopopulates an attribute field based on feature class name for feature classes contained in the TOC of an MXD or even better, a geodatabase? I can???t seem to get a handle on this and have spent ages in the python forum. My start was something like this :-

import arcpy
mxd = arcpy.mapping.MapDocument(r"CURRENT")
fcs = arcpy.ListFeatureClasses(mxd)
fc = fcs.Next()
while fc:
arcpy.CalculateField_management (fc, "FILENAME", '"' + fc + '"')
fc = fcs.Next()
print "done