How To: Use Python to list the data sources of all layers in the table of contents of a map document
The instructions below describe the steps to use Python code to list the data source for each layer in an MXD’s table of contents.
- Open the MXD that contains the layers to use for the listing.
- Open the Python window by clicking the Python button on the Standard toolbar.
- Paste the following code into the Python window:
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
print "Layer: " + lyr.name + " Source: " + lyr.dataSource
- Press Enter. The code prints the layer name and source for all layers in the MXD.
Article ID: 000011530
Software: ArcGIS - ArcEditor 10 ArcGIS - ArcInfo 10 ArcGIS - ArcView 10