<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic list layers in maps in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160699#M1781</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Folks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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 &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;desc = arcpy.Describe(map)&lt;/SPAN&gt;&lt;SPAN&gt; will not return a path.&amp;nbsp; Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Loop through all MXDs in the specified folder and list layers in each MXD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;folderPath = r"mydata"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = folderPath&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;maps = arcpy.ListFiles("*.mxd")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # makes a list of maps in folderPath&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for map in maps:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]desc = arcpy.Describe(map)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # make a describe object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mappath = desc.path + '\\'+ desc.file&amp;nbsp; #build a path to the map&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print mappath&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyrlist = arcpy.mapping.ListLayers(mxd) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for lyr in lyrlist:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]print lyr.dataSource[/INDENT][/INDENT]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 May 2014 19:08:19 GMT</pubDate>
    <dc:creator>stansovern</dc:creator>
    <dc:date>2014-05-22T19:08:19Z</dc:date>
    <item>
      <title>list layers in maps</title>
      <link>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160699#M1781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Folks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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 &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;desc = arcpy.Describe(map)&lt;/SPAN&gt;&lt;SPAN&gt; will not return a path.&amp;nbsp; Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Loop through all MXDs in the specified folder and list layers in each MXD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;folderPath = r"mydata"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = folderPath&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;maps = arcpy.ListFiles("*.mxd")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # makes a list of maps in folderPath&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for map in maps:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]desc = arcpy.Describe(map)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # make a describe object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mappath = desc.path + '\\'+ desc.file&amp;nbsp; #build a path to the map&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print mappath&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyrlist = arcpy.mapping.ListLayers(mxd) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for lyr in lyrlist:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]print lyr.dataSource[/INDENT][/INDENT]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 19:08:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160699#M1781</guid>
      <dc:creator>stansovern</dc:creator>
      <dc:date>2014-05-22T19:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: list layers in maps</title>
      <link>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160700#M1782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm surprised this works at all for you. &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;Describe&lt;/SPAN&gt;&lt;SPAN&gt; is not the appropriate function to use here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;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:
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd_path = os.path.join(env.workspace, map)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mxd_path
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(mxd)
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrlist = arcpy.mapping.ListLayers(mxd)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for lyr in lyrlist:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.dataSource&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:27:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160700#M1782</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-11T08:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: list layers in maps</title>
      <link>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160701#M1783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;looking at your code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;lyrlist = arcpy.mapping.ListLayers(mxd) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;should be&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;lyrlist = arcpy.mapping.ListLayers(map) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you never create a variable called mxd, you'd probably need to substitute it with your local variable map, as it refer to the map in your list of map files.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 19:15:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160701#M1783</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-05-22T19:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: list layers in maps</title>
      <link>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160702#M1784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Awesome Jason, thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 19:26:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/list-layers-in-maps/m-p/160702#M1784</guid>
      <dc:creator>stansovern</dc:creator>
      <dc:date>2014-05-22T19:26:48Z</dc:date>
    </item>
  </channel>
</rss>

