Outputting same name as input using Copy Features

370
11
Jump to solution
07-08-2020 09:21 AM
AliciaShyu
New Contributor III

I'm writing a script that has 30+ layers and a boundary layer. I need to copy all the layers that intersect with the boundary to a GDB. 

I have the following for the "Select layer by location" tool

# Select by location all layers that intersect with AirBound and copy selection to GBD
= aprx.listMaps("Test")[0]
for layer in m.listLayers():
    if layer.name != AirBound:
        arcpy.SelectLayerByLocation_management (layer, "INTERSECT", AirBound)
        print (arcpy.GetMessages())

Is there any way to use "Copy Features" tool  where the output name is the same as the input name?

Thanks!

0 Kudos
11 Replies
AliciaShyu
New Contributor III

This is a monthly recurring task. So every month the old GDB will be deleted and a new one created. After the new one is created, all the layers (records in each layer) that intersect with the AirBound layer will be copied to the new GDB. 

0 Kudos
JoeBorgione
MVP Esteemed Contributor

Let's follow Josh's lead from just above; his point is what I'm getting at at.

can't wait to retire....
0 Kudos