<?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: Renaming a shapefile in Python 2.7 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103566#M7994</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the naming convention is consistent, i.e., you always want everything after an underscore, does this work for you?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"dbo.vNT_Fence.shp"&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; name&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"_"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'Fence.shp'&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Rename_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; name&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"_"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 06:21:55 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2021-12-11T06:21:55Z</dc:date>
    <item>
      <title>Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103560#M7988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys&lt;/P&gt;&lt;P&gt;I have a python script (written in 2.7) with takes a shapefile, renames it and then imports it into a SDE geodatabase. The creators of the shapefile have recently changed the file name to have a full stop halfway through the name which now causes the script to crash.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried running the following&amp;nbsp;section of python to rename the shapefile but it only renames the .shp file and no other files that are part of the shapefile:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "C:\\Users\\blythe schembri\\Downloads"&lt;BR /&gt;datasets&amp;nbsp;= arcpy.ListFeatureClasses()&lt;BR /&gt;for fc in datasets:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CorrectName = fc.replace('dbo.vNT_','')&lt;BR /&gt;arcpy.Rename_management(fc, CorrectName[:-4])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I make it rename all the shapefile components?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Blythe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2019 02:20:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103560#M7988</guid>
      <dc:creator>BlytheSchembri1</dc:creator>
      <dc:date>2019-09-10T02:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103561#M7989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'd want to use python (not arcpy) to rename all the files. But... Since your moving the shape file why not just rename it as you move it to your egdb?&amp;nbsp; See&amp;nbsp;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm" title="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm"&gt;Copy Features—Data Management toolbox | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2019 03:27:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103561#M7989</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-09-10T03:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103562#M7990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you provide a sample or example of a new shape file name?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2019 14:32:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103562#M7990</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-09-10T14:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103563#M7991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An example new name would be Fences.shp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2019 22:52:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103563#M7991</guid>
      <dc:creator>BlytheSchembri1</dc:creator>
      <dc:date>2019-09-10T22:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103564#M7992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about an example of the original/old name with the full stop in it?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2019 22:59:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103564#M7992</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-09-10T22:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103565#M7993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;An example is dbo.vNT_Fence.shp&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2019 00:02:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103565#M7993</guid>
      <dc:creator>BlytheSchembri1</dc:creator>
      <dc:date>2019-09-11T00:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103566#M7994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the naming convention is consistent, i.e., you always want everything after an underscore, does this work for you?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"dbo.vNT_Fence.shp"&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; name&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"_"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'Fence.shp'&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Rename_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; name&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"_"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:21:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103566#M7994</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T06:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103567#M7995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've had a chance to try making this script work again. Thank you all for your help.&lt;/P&gt;&lt;P&gt;I think I'm going to go with the copy features option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code above only renames the .shp file and not the others.&amp;nbsp;In theory do I need to use a wildcard instead of .shp?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Blythe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Sep 2019 23:14:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103567#M7995</guid>
      <dc:creator>BlytheSchembri1</dc:creator>
      <dc:date>2019-09-18T23:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103568#M7996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The Rename tool only renames the *.shp file and not the associated files?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2019 01:05:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103568#M7996</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-09-19T01:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103569#M7997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep! very weird.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've even exported the python script from ArcMap and when I run it outside ArcGIS it only renames the *.shp file&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2019 01:10:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103569#M7997</guid>
      <dc:creator>BlytheSchembri1</dc:creator>
      <dc:date>2019-09-19T01:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming a shapefile in Python 2.7</title>
      <link>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103570#M7998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm" title="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/copy-features.htm"&gt;Copy Features—Data Management toolbox | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;would be your best option to recreate the old shapefile under a new name and to make a featureclass.&lt;/P&gt;&lt;P&gt;Your original would be retained, and could be archived if needed or dumped via windows explorer&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2019 08:08:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-a-shapefile-in-python-2-7/m-p/103570#M7998</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-09-19T08:08:52Z</dc:date>
    </item>
  </channel>
</rss>

