<?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 Import and Rename .mapx Files Python Question in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/import-and-rename-mapx-files-python-question/m-p/1401658#M81051</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Looking to see if I can fix the following code block. I want to import .mapx docs into a Pro project and rename them with the name of the mapx filename. I was successful at importing them in an earlier version without the names, but wanted to rename them because they get named as "Layers1"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

workspace = r"S:\GeoInfo\All_Staff\Kyle_S\python_notebooks\Test"

aprx = arcpy.mp.ArcGISProject(r"S:\GeoInfo\All_Staff\Kyle_S\python_notebooks\Test\ImportMapDocs.aprx")

for root, dirs, files in os.walk(workspace):
    for file in files:
        if file.endswith(".mapx"):
            mapx_path = os.path.join(root, file)
            print("MAPX Path :" + mapx_path)
            mapx_basename = os.path.splitext(os.path.basename(mapx_path))[0]
            print("MAPX NAME :" +  mapx_basename)
            new_map = aprx.importDocument(mapx_path)
            new_map.name = mapx_basename
            print(f"Imported and renamed {file}  into the Import Docs project")
aprx.save()
del aprx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get an Error saying 'Nonetype' object has no attribute name. Seems I have to define a new map object somehow?&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2024 19:50:31 GMT</pubDate>
    <dc:creator>Smileyk_mdt</dc:creator>
    <dc:date>2024-03-27T19:50:31Z</dc:date>
    <item>
      <title>Import and Rename .mapx Files Python Question</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/import-and-rename-mapx-files-python-question/m-p/1401658#M81051</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Looking to see if I can fix the following code block. I want to import .mapx docs into a Pro project and rename them with the name of the mapx filename. I was successful at importing them in an earlier version without the names, but wanted to rename them because they get named as "Layers1"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

workspace = r"S:\GeoInfo\All_Staff\Kyle_S\python_notebooks\Test"

aprx = arcpy.mp.ArcGISProject(r"S:\GeoInfo\All_Staff\Kyle_S\python_notebooks\Test\ImportMapDocs.aprx")

for root, dirs, files in os.walk(workspace):
    for file in files:
        if file.endswith(".mapx"):
            mapx_path = os.path.join(root, file)
            print("MAPX Path :" + mapx_path)
            mapx_basename = os.path.splitext(os.path.basename(mapx_path))[0]
            print("MAPX NAME :" +  mapx_basename)
            new_map = aprx.importDocument(mapx_path)
            new_map.name = mapx_basename
            print(f"Imported and renamed {file}  into the Import Docs project")
aprx.save()
del aprx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get an Error saying 'Nonetype' object has no attribute name. Seems I have to define a new map object somehow?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 19:50:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/import-and-rename-mapx-files-python-question/m-p/1401658#M81051</guid>
      <dc:creator>Smileyk_mdt</dc:creator>
      <dc:date>2024-03-27T19:50:31Z</dc:date>
    </item>
  </channel>
</rss>

