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:
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
I am sure there is something simple, but I am *very* new at Python.
If you google that error number (esri error 000732) you'll find https://support.esri.com/en/technical-article/000010149 which just describes what's going on. Looking at the arcpy.Rename_management() method help, it appears to work for actual data sets rather than a layout object.
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. Perhaps someone else knows?