<?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 Re: Print list of maps and layers across multiple ArcGISProject()'s in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333544#M68922</link>
    <description>&lt;P&gt;Well,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/115587"&gt;@MobiusSnake&lt;/a&gt;&amp;nbsp;got me on the right "path" here ;-).&amp;nbsp; I've tried feeding the path and file into os.path.isfile() in a number of tricky ways... here is my latest attempt:&lt;/P&gt;&lt;P&gt;# For loop with file listing&lt;BR /&gt;import arcpy, os.path&lt;/P&gt;&lt;P&gt;with open(r"C:\GISData\aprx_list.txt") as aprx_files:&lt;BR /&gt;&amp;nbsp; for aprxPathFile in aprx_files:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; aprxPathFile = 'r{}'.format(aprxPathFile)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print(aprxPathFile)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if os.path.isfile(aprxPathFile):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aprx = arcpy.mp.ArcGISProject(aprxPathFile)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; for m in aprx.listMaps():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print("Map: " + m.name)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for lyr in m.listLayers():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(" " + lyr.name)&lt;/P&gt;&lt;P&gt;The print(aprxPathFile) prints out the results as:&lt;/P&gt;&lt;P&gt;r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\fixit\fixit.aprx"&lt;/P&gt;&lt;P&gt;r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject\MyProject.aprx"&lt;/P&gt;&lt;P&gt;r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject1\MyProject1.aprx"&lt;/P&gt;&lt;P&gt;r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject2\MyProject2.aprx"&lt;/P&gt;&lt;P&gt;But os.path.isfile(aprxPathFile) returns False.&amp;nbsp; Spooky part?&amp;nbsp; I can copy the path and file text from one of these entries, paste it in to os.path.isfile() and I get True!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Sep 2023 19:30:38 GMT</pubDate>
    <dc:creator>JackVan_Schenck</dc:creator>
    <dc:date>2023-09-28T19:30:38Z</dc:date>
    <item>
      <title>Print list of maps and layers across multiple ArcGISProject()'s</title>
      <link>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1332995#M68918</link>
      <description>&lt;P&gt;Hi guys!&amp;nbsp; My subject is pretty descriptive, but trying to figure out how to get this basic script to run!&amp;nbsp; I've attempted running it from the Python windows within a Pro session and outside from the command line.&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;with open(r"C:\GISData\aprx_list.txt") as aprx_files:&lt;BR /&gt;for aprxPathFile in aprx_files:&lt;BR /&gt;print(aprxPathFile)&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject(aprxPathFile)&lt;BR /&gt;for m in aprx.listMaps():&lt;BR /&gt;print("Map: " + m.name)&lt;BR /&gt;for lyr in m.listLayers():&lt;BR /&gt;print(" " + lyr.name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Contents of "aprx_list.txt" is:&lt;/P&gt;&lt;P&gt;C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\fixit\\fixit.aprx&lt;BR /&gt;C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\MyProject\\MyProject.aprx&lt;BR /&gt;C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\MyProject1\\MyProject1.aprx&lt;BR /&gt;C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\MyProject2\\MyProject2.aprx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, the result and error I'm getting from both environments is:&lt;/P&gt;&lt;P&gt;C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\fixit\\fixit.aprx&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 6, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 536, in __init__&lt;BR /&gt;self._arc_object = arcgisscripting._mapping.ArcGISProject(*gp_fixargs((aprx_path,), True))&lt;BR /&gt;OSError: C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\fixit\\fixit.aprx&lt;/P&gt;&lt;P&gt;Thanks in advance for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 17:01:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1332995#M68918</guid>
      <dc:creator>JackVan_Schenck</dc:creator>
      <dc:date>2023-09-27T17:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Print list of maps and layers across multiple ArcGISProject()'s</title>
      <link>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333004#M68919</link>
      <description>&lt;P&gt;Do those files definitely exist?&amp;nbsp; That's the message you'll get when trying to open an APRX that doesn't exist.&amp;nbsp; You can use arcpy.Exists() to check that a file exists before opening it.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 17:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333004#M68919</guid>
      <dc:creator>MobiusSnake</dc:creator>
      <dc:date>2023-09-27T17:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Print list of maps and layers across multiple ArcGISProject()'s</title>
      <link>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333011#M68920</link>
      <description>&lt;P&gt;Good question - they definitely exist (although I whiteboarded the gis_user and Company parts of the paths in this post for privacy).&amp;nbsp; Came from doing an old school "dir /s /b &amp;gt; aprx_list.txt", then doing a find and replace to get the double slashes for Python's persnickety behavior with spaces.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 17:27:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333011#M68920</guid>
      <dc:creator>JackVan_Schenck</dc:creator>
      <dc:date>2023-09-27T17:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Print list of maps and layers across multiple ArcGISProject()'s</title>
      <link>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333013#M68921</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/115587"&gt;@MobiusSnake&lt;/a&gt;&amp;nbsp;- I just put a file.exists() through os.path... looks like I just need to escape those "\\" delimiters from the text file!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 17:33:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333013#M68921</guid>
      <dc:creator>JackVan_Schenck</dc:creator>
      <dc:date>2023-09-27T17:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Print list of maps and layers across multiple ArcGISProject()'s</title>
      <link>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333544#M68922</link>
      <description>&lt;P&gt;Well,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/115587"&gt;@MobiusSnake&lt;/a&gt;&amp;nbsp;got me on the right "path" here ;-).&amp;nbsp; I've tried feeding the path and file into os.path.isfile() in a number of tricky ways... here is my latest attempt:&lt;/P&gt;&lt;P&gt;# For loop with file listing&lt;BR /&gt;import arcpy, os.path&lt;/P&gt;&lt;P&gt;with open(r"C:\GISData\aprx_list.txt") as aprx_files:&lt;BR /&gt;&amp;nbsp; for aprxPathFile in aprx_files:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; aprxPathFile = 'r{}'.format(aprxPathFile)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print(aprxPathFile)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if os.path.isfile(aprxPathFile):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aprx = arcpy.mp.ArcGISProject(aprxPathFile)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; for m in aprx.listMaps():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print("Map: " + m.name)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for lyr in m.listLayers():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(" " + lyr.name)&lt;/P&gt;&lt;P&gt;The print(aprxPathFile) prints out the results as:&lt;/P&gt;&lt;P&gt;r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\fixit\fixit.aprx"&lt;/P&gt;&lt;P&gt;r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject\MyProject.aprx"&lt;/P&gt;&lt;P&gt;r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject1\MyProject1.aprx"&lt;/P&gt;&lt;P&gt;r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject2\MyProject2.aprx"&lt;/P&gt;&lt;P&gt;But os.path.isfile(aprxPathFile) returns False.&amp;nbsp; Spooky part?&amp;nbsp; I can copy the path and file text from one of these entries, paste it in to os.path.isfile() and I get True!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 19:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/print-list-of-maps-and-layers-across-multiple/m-p/1333544#M68922</guid>
      <dc:creator>JackVan_Schenck</dc:creator>
      <dc:date>2023-09-28T19:30:38Z</dc:date>
    </item>
  </channel>
</rss>

