stan_esri

list layers in maps

Discussion created by stan_esri on May 22, 2014
Latest reply on May 22, 2014 by stan_esri
Hi Folks,
I'm trying to generate a list of maps, and the layers in those maps in python. This script works once, then the line that brings up the path desc = arcpy.Describe(map) will not return a path.  Any ideas?

import arcpy
from arcpy import env


# Loop through all MXDs in the specified folder and list layers in each MXD
folderPath = r"mydata"
env.workspace = folderPath
maps = arcpy.ListFiles("*.mxd")       # makes a list of maps in folderPath
for map in maps:
[INDENT]desc = arcpy.Describe(map)        # make a describe object
mappath = desc.path + '\\'+ desc.file  #build a path to the map
print mappath
lyrlist = arcpy.mapping.ListLayers(mxd)
for lyr in lyrlist:
[INDENT]print lyr.dataSource[/INDENT][/INDENT]

Outcomes