<?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: Python script- changing layer's name in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527567#M5711</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Joshua says, your df name is wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would use something like&lt;/P&gt;&lt;P&gt;df = arcpy.mapping.ListDataFrames(mxd, "")[0] or df = arcpy.mapping.ListDataFrames(mxd, "Mexico")[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then no need for if df,name == , just use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;layers = arcpy.mapping.ListLayers(mxd,'states',df)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Mar 2016 14:13:03 GMT</pubDate>
    <dc:creator>AnthonyFarndon</dc:creator>
    <dc:date>2016-03-30T14:13:03Z</dc:date>
    <item>
      <title>Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527556#M5700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I do not know why the following python script does not work and cause a change of the layer's name (from 'States' to 'Stany'). After running the script I have received the message:" script returned exit code 0". Any suggestions? Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy.mapping&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("F:/DSW/Using_ArcGIS_Desktop/MexicoPopulationDensity.mxd")&lt;/P&gt;&lt;P&gt;for df in arcpy.mapping.ListDataFrames(mxd):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (df.name == 'States'):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers = arcpy.mapping.ListLayers(mxd,'Stany',df)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 07:31:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527556#M5700</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-30T07:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527557#M5701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;maybe you need to mxd.save() before the changes persist&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/mapdocument-class.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/mapdocument-class.htm"&gt;MapDocument—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 08:13:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527557#M5701</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-30T08:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527558#M5702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately, it doesn't help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 08:26:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527558#M5702</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-30T08:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527559#M5703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok, add an else portion to the if ... python is exiting without doing anything&lt;/P&gt;&lt;P&gt;if ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do stuff&lt;/P&gt;&lt;P&gt;else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print('not found')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 08:34:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527559#M5703</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-30T08:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527560#M5704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My python code looks like this now:&lt;/P&gt;&lt;P&gt;for df in arcpy.mapping.ListDataFrames(mxd):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (df.name == 'states'):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers = arcpy.mapping.ListLayers(mxd,'Stany',df)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print('not found')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.saveACopy&amp;nbsp; &lt;/P&gt;&lt;P&gt;I have received the message 'not found', but the layer is the project folder.&lt;BR /&gt;&lt;IMG alt="layers.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/193408_layers.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I suppose that the problem is associated with refreshing. &lt;BR /&gt;As I have changed the name of shp file -&amp;gt; from States to states and use python to print the name of the layers, I have received the same result as BEFORE the change. So instead of: &lt;/P&gt;&lt;P&gt;Cities&lt;BR /&gt;states&lt;BR /&gt;Lakes&lt;/P&gt;&lt;P&gt;Mexico Bnd&lt;/P&gt;&lt;P&gt;Central America Bnd&lt;/P&gt;&lt;P&gt;USA Bnd, I have got:&lt;/P&gt;&lt;P&gt;Cities&lt;/P&gt;&lt;P&gt;Lakes&lt;/P&gt;&lt;P&gt;Mexico Bnd&lt;/P&gt;&lt;P&gt;States&lt;/P&gt;&lt;P&gt;Central America Bnd&lt;/P&gt;&lt;P&gt;USA Bnd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please give me advice how to solve this problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 09:02:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527560#M5704</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-30T09:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527561#M5705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is mxd defined as "Current" somewhere? that seems to be the piece that is missing for me... Did you read the link I sent you? The project has to be named as on disk or if you are working interactively, then with the Current keyword.&amp;nbsp; Also, you are in source view in the table of contents, ... go to the data view (to the left of your current selection) to ensure that the layer is named "states" and not "States"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 09:07:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527561#M5705</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-30T09:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527562#M5706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the whole python code:&lt;/P&gt;&lt;P&gt;import arcpy.mapping&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("F:/DSW/Using_ArcGIS_Desktop/MexicoPopulation.mxd")&lt;/P&gt;&lt;P&gt;print mxd.title&lt;/P&gt;&lt;P&gt;layers = arcpy.mapping.ListLayers(mxd)&lt;/P&gt;&lt;P&gt;for lyr in layers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.name&lt;/P&gt;&lt;P&gt;for df in arcpy.mapping.ListDataFrames(mxd):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (df.name == 'states'):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layers = arcpy.mapping.ListLayers(mxd,'Stany',df)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print('not found')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.saveACopy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not use CURRENT keyword, because I do not run a script from ArcGIS Python window, but from the PythonWin. Instead of that I put the correct pathfile of the *.mxd file and all *shp. files, which are included in this project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The layer name is states. And now after loding the script once again, I have received the correct answer.&lt;BR /&gt;Unfortunately, the problem with changing the name of the layer states to Stany still remains... &lt;BR /&gt;Have you got any other ideas? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 09:30:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527562#M5706</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-30T09:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527563#M5707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I have read this link, but I could not find there the answer to my problem.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 09:33:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527563#M5707</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-30T09:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527564#M5708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG alt="LayoutView.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/193412_LayoutView.png" style="width: 620px; height: 337px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 09:34:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527564#M5708</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-30T09:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527565#M5709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;Yes, I have read this link, but I could not find there the answer to my problem. This is the layout view:&lt;BR /&gt;&lt;IMG alt="LayoutView.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/193413_LayoutView.png" style="width: 620px; height: 337px;" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 09:35:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527565#M5709</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-30T09:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527566#M5710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your data frame name is "Mexico," you are never going to find your 'states' layer if it is nested within your &lt;SPAN style="font-family: courier new,courier;"&gt;df.name == 'states'&lt;/SPAN&gt; statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 13:48:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527566#M5710</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-03-30T13:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527567#M5711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Joshua says, your df name is wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would use something like&lt;/P&gt;&lt;P&gt;df = arcpy.mapping.ListDataFrames(mxd, "")[0] or df = arcpy.mapping.ListDataFrames(mxd, "Mexico")[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then no need for if df,name == , just use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;layers = arcpy.mapping.ListLayers(mxd,'states',df)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 14:13:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527567#M5711</guid>
      <dc:creator>AnthonyFarndon</dc:creator>
      <dc:date>2016-03-30T14:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527568#M5712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Anthony for your message.&lt;BR /&gt;I have changed my code into the following;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import arcpy.mapping&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;df=arcpy.mapping.ListDataFrames(mxd,"Mexico")[0]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;layers = arcpy.mapping.ListLayers(mxd,'states',df)&lt;/STRONG&gt;&lt;BR /&gt;but there is nothing about changing the name of a feature class from 'states' to 'stany', so the result is still the same...&lt;BR /&gt;Don't I need to use for..if clause in order to change the name of a feature class?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 05:39:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527568#M5712</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-31T05:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527569#M5713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Like a lot of things, there are many ways to achieve what you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;layers = arcpy.mapping.ListLayers(mxd,'states',df)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;will return a list of all layers named states, so you could loop through it to change the name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;for lyr in layers:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.name = "stany"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However if there is only one layer likely to be called states in the mxd, a shorthand way of achieving this is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;lyr&lt;/STRONG&gt;&lt;STRONG&gt; = arcpy.mapping.ListLayers(mxd,'states',df)[0]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;lyr.name = "stany"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doing an if == is useful if you are wanting to loop through many layers of differing names. eg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;layers = arcpy.mapping.ListLayers(mxd,'',df)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;for lyr in layers:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.name == "states":&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.name = "stany"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif lyr.name == "Lakes":&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.name = "Lakey"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or to do more complex 'stuff' with name matches than the ListLayers wildcard parameter allows, such as ignoring case.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if lyr.name.lower() == "states":&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, if you are doing this with the mxd open, add in the following to see the changes on screen&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.RefreshTOC()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And save the mxd if required&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;mxd.save()&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 10:12:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527569#M5713</guid>
      <dc:creator>AnthonyFarndon</dc:creator>
      <dc:date>2016-03-31T10:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527570#M5714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for your help &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 10:41:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527570#M5714</guid>
      <dc:creator>MalgorzataMendela</dc:creator>
      <dc:date>2016-03-31T10:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python script- changing layer's name</title>
      <link>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527571#M5715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please mark Anthony's response Correct if it answered your question.&amp;nbsp; That way, it lets others know the question has been answered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 13:38:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-script-changing-layer-s-name/m-p/527571#M5715</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-03-31T13:38:49Z</dc:date>
    </item>
  </channel>
</rss>

