<?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: Delete text from multiple mxds - python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-text-from-multiple-mxds-python/m-p/406042#M31955</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does this text element have an element name?&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/154043_pastedImage_2.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;I think you might be looking for something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

env.workspace = # Folder with mxds

for mxds in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; filePath = os.path.join(env.workspace, mxds)
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(filePath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "Draft":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()
&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There may be a way to actually delete the text box, but this code will at least replace the "Draft" text with an empty string, if the element name is called "Draft".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do not have an element name then you could use something like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

env.workspace = # Folder with mxds

for mxds in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; filePath = os.path.join(env.workspace, mxds)
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(filePath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.text == "Draft":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()
&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 18:28:03 GMT</pubDate>
    <dc:creator>LukeSturtevant</dc:creator>
    <dc:date>2021-12-11T18:28:03Z</dc:date>
    <item>
      <title>Delete text from multiple mxds - python</title>
      <link>https://community.esri.com/t5/python-questions/delete-text-from-multiple-mxds-python/m-p/406041#M31954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have multiple mxds containing the word "draft" in a text box.&amp;nbsp; I'm looking for a python script that will allow me to point to the mxd's home folder on our file server and delete the text box from each mxd file.&amp;nbsp; Has anyone created such a script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Dec 2015 18:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-text-from-multiple-mxds-python/m-p/406041#M31954</guid>
      <dc:creator>melsoares</dc:creator>
      <dc:date>2015-12-09T18:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text from multiple mxds - python</title>
      <link>https://community.esri.com/t5/python-questions/delete-text-from-multiple-mxds-python/m-p/406042#M31955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does this text element have an element name?&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/154043_pastedImage_2.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;I think you might be looking for something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

env.workspace = # Folder with mxds

for mxds in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; filePath = os.path.join(env.workspace, mxds)
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(filePath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "Draft":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()
&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There may be a way to actually delete the text box, but this code will at least replace the "Draft" text with an empty string, if the element name is called "Draft".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you do not have an element name then you could use something like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

env.workspace = # Folder with mxds

for mxds in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; filePath = os.path.join(env.workspace, mxds)
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(filePath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.text == "Draft":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()
&amp;nbsp;&amp;nbsp;&amp;nbsp; del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:28:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-text-from-multiple-mxds-python/m-p/406042#M31955</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2021-12-11T18:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Delete text from multiple mxds - python</title>
      <link>https://community.esri.com/t5/python-questions/delete-text-from-multiple-mxds-python/m-p/406043#M31956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for passing this on, Luke.&amp;nbsp; After a few tweaks, I got the second script to work (the text boxes did not have an element name).&lt;/P&gt;&lt;P&gt;Two things for other readers:&lt;/P&gt;&lt;P&gt;I had to change line 1 to read: import os, arcpy&lt;/P&gt;&lt;P&gt;I had to add a space between the quotation marks in line 11.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Dec 2015 15:27:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-text-from-multiple-mxds-python/m-p/406043#M31956</guid>
      <dc:creator>melsoares</dc:creator>
      <dc:date>2015-12-10T15:27:27Z</dc:date>
    </item>
  </channel>
</rss>

