<?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: How to: Alter text elements in multiple MXDs simultaneously using a Python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556445#M73151</link>
    <description>&lt;P&gt;Thought you had something there. I changed that at some point while debugging and forgot to put it back the way it was. Didn't make a difference.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2024 18:42:03 GMT</pubDate>
    <dc:creator>JaredPilbeam2</dc:creator>
    <dc:date>2024-11-07T18:42:03Z</dc:date>
    <item>
      <title>How to: Alter text elements in multiple MXDs simultaneously using a Python script</title>
      <link>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556393#M73148</link>
      <description>&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-alter-text-elements-in-multiple-mxds-simultaneou-000015333" target="_blank"&gt;https://support.esri.com/en-us/knowledge-base/how-to-alter-text-elements-in-multiple-mxds-simultaneou-000015333&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Is there an updated version of this for Pro? When I use the script with Pro-related updates there are no errors in the tool, but no changes are made. I'm currently debugging and the couple things I'm questioning whether they're actually doing their job are the &lt;EM&gt;counter&lt;/EM&gt; and &lt;EM&gt;replace()&lt;/EM&gt;.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
arcpy.env.overwriteOutput = True

#workspace folder
arcpy.env.workspace = ws = arcpy.GetParameterAsText(0)
Old_Text = arcpy.GetParameterAsText(1)
oldList = Old_Text.split(', ') #set the comma as separator for multiple inputs
New_Text = arcpy.GetParameterAsText(2)
newList = New_Text.split(', ')

f = arcpy.ListFiles("*.aprx")
for aprxname in f:
    aprx_path = os.path.join(ws, aprxname)
    aprx = arcpy.mp.ArcGISProject(aprx_path)
    for lyt in aprx.listLayouts():
        for elm in lyt.listElements('TEXT_ELEMENT'):
            counter = 0
            for text in oldList:
                if text in elm.text:
                    elm.text.replace(text,newList[counter])
                    arcpy.AddMessage(f'{aprxname} | updated to: {elm.text}')
                    counter = counter + 1
                else:
                    counter = counter + 1
    aprx.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JaredPilbeam2_0-1731000143738.png" style="width: 792px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119057i5F519B1AB3A862A6/image-dimensions/792x105?v=v2" width="792" height="105" role="button" title="JaredPilbeam2_0-1731000143738.png" alt="JaredPilbeam2_0-1731000143738.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JaredPilbeam2_1-1731000210378.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119058i87BE2E03F283CCBE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JaredPilbeam2_1-1731000210378.png" alt="JaredPilbeam2_1-1731000210378.png" /&gt;&lt;/span&gt;&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 17:26:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556393#M73148</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2024-11-07T17:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Alter text elements in multiple MXDs simultaneously using a Python script</title>
      <link>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556420#M73149</link>
      <description>&lt;P&gt;replace&lt;/P&gt;&lt;LI-CODE lang="c"&gt;elm.text.replace(text, newList[counter])&lt;/LI-CODE&gt;&lt;P&gt;with&lt;/P&gt;&lt;LI-CODE lang="c"&gt;elm.text = elm.text.replace(text, newList[counter])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 17:56:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556420#M73149</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-11-07T17:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Alter text elements in multiple MXDs simultaneously using a Python script</title>
      <link>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556445#M73151</link>
      <description>&lt;P&gt;Thought you had something there. I changed that at some point while debugging and forgot to put it back the way it was. Didn't make a difference.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 18:42:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556445#M73151</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2024-11-07T18:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Alter text elements in multiple MXDs simultaneously using a Python script</title>
      <link>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556484#M73152</link>
      <description>&lt;P&gt;Maybe try,&lt;/P&gt;&lt;LI-CODE lang="c"&gt;arcpy.mp.ArcGISProject(aprx_path)
    for lyt in aprx.listLayouts():
        for elm in lyt.listElements('TEXT_ELEMENT'):
            counter = 0
            for text in oldList:
                if text in elm.text:
                    elm.text = elm.text.replace(text, newList[counter])
                    arcpy.AddMessage(f'{aprxname} | updated to: {elm.text}')
                counter += 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 19:49:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556484#M73152</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-11-07T19:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Alter text elements in multiple MXDs simultaneously using a Python script</title>
      <link>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556492#M73153</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3265"&gt;@TonyAlmeida&lt;/a&gt;&amp;nbsp;After implementing your suggestion, I did some further debugging and found the problem. These two parameters require a space after the separator when imputing multiple values, and I wasn't doing that.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;oldList = Old_Text.split(', ')&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;newList = New_Text.split(', ')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, if you have a space in the &lt;EM&gt;split()&lt;/EM&gt; function then you need to put it after the parameter value too. Also, make sure your old text matches your existing layout text element or else it won't be found.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JaredPilbeam2_0-1731009628059.png" style="width: 345px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/119082i600E1E67BDC4D576/image-dimensions/345x279?v=v2" width="345" height="279" role="button" title="JaredPilbeam2_0-1731009628059.png" alt="JaredPilbeam2_0-1731009628059.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Working in Pro 3.3.2&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
arcpy.env.overwriteOutput = True

#workspace folder
arcpy.env.workspace = ws = arcpy.GetParameterAsText(0)
Old_Text = arcpy.GetParameterAsText(1)
oldList = Old_Text.split(', ') #split into a list, use comma and space as separator
New_Text = arcpy.GetParameterAsText(2)
newList = New_Text.split(', ')


f = arcpy.ListFiles("*.aprx")
for aprxname in f:
    aprx_path = os.path.join(ws, aprxname)
    aprx = arcpy.mp.ArcGISProject(aprx_path)
    for lyt in aprx.listLayouts():
        for elm in lyt.listElements('TEXT_ELEMENT'):
            counter = 0
            for text in oldList:
                if text in elm.text:
                    elm.text = elm.text.replace(text,newList[counter])
                    arcpy.AddMessage(f'{aprxname} | updated to: {elm.text}')
                    counter = counter + 1
                else:
                    counter = counter + 1
    aprx.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 20:05:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-alter-text-elements-in-multiple-mxds/m-p/1556492#M73153</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2024-11-07T20:05:48Z</dc:date>
    </item>
  </channel>
</rss>

