I am trying to remove anything in a map that has "DI" in the source path.
I have a test mxd with one df and 2 lyr's. The lyr data sources are:
C:\Users\Corey.Fields\Python\Testing\DI_Remove\Fake_DI_Wells.shp S:\Departments\GIS\ARCUSERS\PERSONAL_FOLDERS\CFields\Test.gdb\Fake_DI_Test
My code is:
import arcpy
mxd = arcpy.mapping.MapDocument("C:\Users\Corey.Fields\Python\Testing\DI_Remove\Untitled.mxd")
for df in arcpy.mapping.ListDataFrames(mxd):
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
if lyr.dataSource == "*DI*":
arcpy.mapping.RemoveLayer(df, lyr)
mxd.save()
del mxd
The script is running but not removing the layers.
What do I have wrong?