I'm trying to find "Signal" in a field named "Maintained by" but there are quite a few layers.

I do not want to go into every single layer and change "Signal" to "Private."

Does anyone know a quick shortcut?

  • You have all layers added to the map? – BERA Jul 28 '18 at 18:58

You can use arcpy. I'm assuming you have all layers you want to change added to the map and no others. Execute the code in the python window.

import arcpy

fieldname = 'Maintained by'
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps("Map")[0]
for lyr in m.listLayers():
    sql = """{0} = 'Signal'""".format(arcpy.AddFieldDelimiters(lyr,fieldname))

    #First try this and make sure correct rows are selected:
    arcpy.SelectLayerByAttribute_management(in_layer_or_view=lyr, where_clause=sql)

    #Then unselect all, remove row above and execute everything including code below
    with arcpy.da.UpdateCursor(lyr,fieldname,sql) as cursor:
        for row in cursor:
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.