This should be easy. 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:
import arcpymxd = 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 mxdThe script is running but not removing the layers. What do I have wrong?
Thanks!
أكثر...
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 arcpymxd = 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 mxdThe script is running but not removing the layers. What do I have wrong?
Thanks!
أكثر...