If you want to remove all attribute indexes from all feature classes in a geodatabase, the following will get the job done:
import arcpy
import os
gdb =
walk = arcpy.da.Walk(gdb, datatype="FeatureClass")
for root, _, fcs in walk:
for fc in fcs:
fc = os.path.join(root, fc)
desc = arcpy.Describe(fc)
OIDFieldName = desc.OIDFieldName
shapeFieldName = desc.shapeFieldName
idxs = [
i.name for i in desc.indexes
if not any(f.name in (OIDFieldName, shapeFieldName) for f in i.fields)
]
arcpy.RemoveIndex_management(fc, idxs)
As much as I provide the code above, I can't say I see the logic behind removing all attribute indexes for most or all feature classes in a geodatabase.
UPDATE: I had to alter my original code because I forgot that Remove Index will fail if either the OID or shape index is passed to it, both of which are returned when getting a list of indexes.