<?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: I need the name of the current MXD (newbie question) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/i-need-the-name-of-the-current-mxd-newbie-question/m-p/660410#M51322</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Still learning.......&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Jul 2011 10:22:17 GMT</pubDate>
    <dc:creator>BobMijwaard</dc:creator>
    <dc:date>2011-07-14T10:22:17Z</dc:date>
    <item>
      <title>I need the name of the current MXD (newbie question)</title>
      <link>https://community.esri.com/t5/python-questions/i-need-the-name-of-the-current-mxd-newbie-question/m-p/660408#M51320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have followed the Python course very recently and just finished my first script. To make it more generic I need to know the name of the current MXD&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the script I use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I get the name of the used mxd. Tried os.path.basename(mxd) but that did not work. Got the error: MapDocument is unsubscriptable&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 09:52:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-the-name-of-the-current-mxd-newbie-question/m-p/660408#M51320</guid>
      <dc:creator>BobMijwaard</dc:creator>
      <dc:date>2011-07-14T09:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: I need the name of the current MXD (newbie question)</title>
      <link>https://community.esri.com/t5/python-questions/i-need-the-name-of-the-current-mxd-newbie-question/m-p/660409#M51321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The reason you cannot get the path is because mxd is an object, not a string path.&amp;nbsp; To get the path, you need to use the filePath property on the MapDocument object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
mapPath = mxd.filePath
fileName = os.path.basename(mapPath)
print fileName
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If your map document isn't saved, you will get returned an empty string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:56:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-the-name-of-the-current-mxd-newbie-question/m-p/660409#M51321</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-12T03:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: I need the name of the current MXD (newbie question)</title>
      <link>https://community.esri.com/t5/python-questions/i-need-the-name-of-the-current-mxd-newbie-question/m-p/660410#M51322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Still learning.......&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 10:22:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/i-need-the-name-of-the-current-mxd-newbie-question/m-p/660410#M51322</guid>
      <dc:creator>BobMijwaard</dc:creator>
      <dc:date>2011-07-14T10:22:17Z</dc:date>
    </item>
  </channel>
</rss>

