<?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: Script Error: Populating mxd document properties with arcpy.mapping module in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-error-populating-mxd-document-properties/m-p/239372#M18650</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks very much Mathew, that minor change worked perfectly! Don't know how I could have missed that :o.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Aug 2011 20:54:05 GMT</pubDate>
    <dc:creator>JamesKellough</dc:creator>
    <dc:date>2011-08-25T20:54:05Z</dc:date>
    <item>
      <title>Script Error: Populating mxd document properties with arcpy.mapping module</title>
      <link>https://community.esri.com/t5/python-questions/script-error-populating-mxd-document-properties/m-p/239370#M18648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN style="font-family:Tahoma;"&gt;Hi folks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Tahoma;"&gt;I am new to the arcpy module at version 10. I have a number of mxd's with the same theme that will ultimately have either the same or very similar document properties. To save time typing, I want to write and run a script from the python window to automatically populate each mxd's document properties. This was pretty easy up until I wanted to populate the &lt;STRONG style="font-style: italic;"&gt;Title &lt;/STRONG&gt;property with the mxd's name. After searching the forums and other online sources it seems the best way to do this is by parsing the filename out of the file path. I found some code samples to help me do this but can't get them to work (see highlighted code below) any help a more proficient python scripter can provide would be greatly appreciated. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Tahoma;"&gt;Here is my code. I am having trouble making the highlighted code work; if I remove it from the script all else works just fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-family: Times New Roman;"&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-family: Times New Roman;"&gt;P = mxd.filePath&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-family: Times New Roman;"&gt;P.split('/')[-1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: red; font-family: Times New Roman;"&gt;mxd.title = P&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;mxd.summary = "blah,blah, blah."&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;mxd.author = "James Kellough"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;mxd.credits = "My Company"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;mxd.description = "blah, blah, blah"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;mxd.tags = "Script, Python, Arcpy"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;del mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;Thanks kindly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Times New Roman;"&gt;James Kellough&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 19:39:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-error-populating-mxd-document-properties/m-p/239370#M18648</guid>
      <dc:creator>JamesKellough</dc:creator>
      <dc:date>2011-08-25T19:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script Error: Populating mxd document properties with arcpy.mapping module</title>
      <link>https://community.esri.com/t5/python-questions/script-error-populating-mxd-document-properties/m-p/239371#M18649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think you need to save your split as a new variable, or overwrite the existing one&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: also the slash is a little out of whack when I tested it, try this "\\"&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd = arcpy.mapping.MapDocument("CURRENT")
P = mxd.filePath
&lt;STRONG&gt;P = P.split("\\")[-1]&lt;/STRONG&gt;
mxd.title = P
mxd.summary = "blah,blah, blah."
mxd.author = "James Kellough"
mxd.credits = "My Company"
mxd.description = "blah, blah, blah"
mxd.tags = "Script, Python, Arcpy"
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:03:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-error-populating-mxd-document-properties/m-p/239371#M18649</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T12:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script Error: Populating mxd document properties with arcpy.mapping module</title>
      <link>https://community.esri.com/t5/python-questions/script-error-populating-mxd-document-properties/m-p/239372#M18650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks very much Mathew, that minor change worked perfectly! Don't know how I could have missed that :o.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 20:54:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-error-populating-mxd-document-properties/m-p/239372#M18650</guid>
      <dc:creator>JamesKellough</dc:creator>
      <dc:date>2011-08-25T20:54:05Z</dc:date>
    </item>
  </channel>
</rss>

