<?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: Renaming Multiple Layouts via arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1020632#M59654</link>
    <description>&lt;P&gt;If you google that error number (esri error 000732) you'll find&amp;nbsp;&lt;A href="https://support.esri.com/en/technical-article/000010149" target="_blank"&gt;https://support.esri.com/en/technical-article/000010149&lt;/A&gt;&amp;nbsp;which just describes what's going on.&amp;nbsp; Looking at the arcpy.Rename_management() method &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/rename.htm" target="_self"&gt;help&lt;/A&gt;, it appears to work for actual data sets rather than a layout object.&lt;/P&gt;&lt;P&gt;I'm not sure what would work for renaming a layout, but I've got a little bit of time before I'm off to zoom-meeting land so I'll keep digging.&amp;nbsp; Perhaps someone else knows?&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2021 19:41:36 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2021-01-27T19:41:36Z</dc:date>
    <item>
      <title>Renaming Multiple Layouts via arcpy</title>
      <link>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1020607#M59652</link>
      <description>&lt;P&gt;I am trying to create a tool that will let me rename multiple layouts one after the other, ideally by replacing just a portion of the name. For example, "City_north_map_projects" and "City_north_map_sites" would become "City_south_map_projects" and "City_south_map_sites". So far, I have tried a number of things. This is the code for the latest attempt:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Set Variables
# aprx = arcpy.mp.ArcGISProject("CURRENT")  # For tool use
aprx = arcpy.mp.ArcGISProject(r"PATH TO THE APRX/APRX.aprx") # Development use. Has 3 layouts: Test_layout, Test_layout1, Test_layout2

for lyt in aprx.listLayouts():  # for each layout in the project
    print(lyt.name)  # print the name
    oldName = lyt.name  # write layout name to variable
    newName = oldName.replace("Test", "Best")  # replaces old text with new 
    print(newName)  # everything works through this line
    # lyt.name = newName  # Doesn't actually rename the layout? Commented out to try arcpy.Rename
    arcpy.Rename_management(oldName,newName)  # Fails here with error 000732&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure there is something simple, but I am *very* new at Python.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 18:58:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1020607#M59652</guid>
      <dc:creator>JamesWilcox1970</dc:creator>
      <dc:date>2021-01-27T18:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming Multiple Layouts via arcpy</title>
      <link>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1020632#M59654</link>
      <description>&lt;P&gt;If you google that error number (esri error 000732) you'll find&amp;nbsp;&lt;A href="https://support.esri.com/en/technical-article/000010149" target="_blank"&gt;https://support.esri.com/en/technical-article/000010149&lt;/A&gt;&amp;nbsp;which just describes what's going on.&amp;nbsp; Looking at the arcpy.Rename_management() method &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/rename.htm" target="_self"&gt;help&lt;/A&gt;, it appears to work for actual data sets rather than a layout object.&lt;/P&gt;&lt;P&gt;I'm not sure what would work for renaming a layout, but I've got a little bit of time before I'm off to zoom-meeting land so I'll keep digging.&amp;nbsp; Perhaps someone else knows?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 19:41:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1020632#M59654</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-01-27T19:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming Multiple Layouts via arcpy</title>
      <link>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1020666#M59658</link>
      <description>&lt;P&gt;I suspected that was the case. I had seen an instance where someone was using Rename() to change folder names, and though it might work with layouts. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 20:24:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1020666#M59658</guid>
      <dc:creator>JamesWilcox1970</dc:creator>
      <dc:date>2021-01-27T20:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming Multiple Layouts via arcpy</title>
      <link>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1036990#M60419</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; aprx =&amp;nbsp;arcpy.mp.ArcGISProject(&lt;/SPAN&gt;&lt;SPAN&gt;r&lt;/SPAN&gt;&lt;SPAN&gt;"filepath&lt;/SPAN&gt;&lt;SPAN&gt;.aprx")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;layout =&amp;nbsp;aprx.listLayouts(&lt;/SPAN&gt;&lt;SPAN&gt;)[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;layout.name&amp;nbsp;==&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"Whatever your layout name is"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;layout.name&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"Name it this&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;del&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;aprx&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 16 Mar 2021 04:35:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1036990#M60419</guid>
      <dc:creator>Christian_035</dc:creator>
      <dc:date>2021-03-16T04:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming Multiple Layouts via arcpy</title>
      <link>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1215216#M65667</link>
      <description>&lt;P&gt;I ended up using a modified version of my original code, but in the ArcGIS Pro Python window:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.GISProject("CURRENT")  # The current project
for lyt in aprx.listLayouts(): # For each layout in the project
    oldName = lyt.name  # Gets the name
    print(oldName)  # For progress checking
    nameSplit = oldName.split("_", 1)  # Splits the name into 2 parts at the _
    keepPart = nameSplit[1]  # Saves the 2nd part to be joined to the new part
    newName = f"RC1222_1223_{keepPart}"  # Constructs new name
    print(newName)  # For progress checking/troubleshooting
    lyt.name = newName  # Sets the layout name to the new name&lt;/LI-CODE&gt;&lt;P&gt;The layout names are things like "&lt;EM&gt;RC1222_map_projects_new&lt;/EM&gt;", and the part I wanted to change was the first part, thus the .split(). This worked like a champ in the Python window.&lt;/P&gt;&lt;P&gt;I'm still exploring how to work this in a Script tool.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 18:47:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-multiple-layouts-via-arcpy/m-p/1215216#M65667</guid>
      <dc:creator>JamesWilcox1970</dc:creator>
      <dc:date>2022-09-22T18:47:39Z</dc:date>
    </item>
  </channel>
</rss>

