<?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 Renaming FCs in a geodatabase using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/renaming-fcs-in-a-geodatabase-using-python/m-p/1289443#M67646</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;I am a beginner,&lt;BR /&gt;I'm not very good at English and I think it's hard to read.&lt;BR /&gt;I need a hint&lt;/PRE&gt;&lt;P&gt;I am new to Python but trying to rename hundreds of feature classes in a geodatabase.&lt;/P&gt;&lt;P&gt;This is the code I have been using that did not work so far:&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;arcpy.env.workspace = r'C:\Users\WK48.TOKYO\Desktop\ooamisi9_r\01_gdb\ooamisi9.gdb'&lt;/P&gt;&lt;P&gt;lstDatasets = arcpy.ListDatasets()&lt;BR /&gt;for dataset in lstDatasets:&lt;BR /&gt;lstFCs = arcpy.ListFeatureClasses("*", "", dataset)&lt;BR /&gt;for fc in lstFCs:&lt;BR /&gt;oldName = str(fc)&lt;BR /&gt;newName = oldName.replace("_FG_GML", "")&lt;BR /&gt;newName = newName.replace("_0001", "")&lt;BR /&gt;arcpy.Rename_management(fc, newName)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I wrote the above code&lt;BR /&gt;No change in database&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2023 02:57:19 GMT</pubDate>
    <dc:creator>taka</dc:creator>
    <dc:date>2023-05-16T02:57:19Z</dc:date>
    <item>
      <title>Renaming FCs in a geodatabase using Python</title>
      <link>https://community.esri.com/t5/python-questions/renaming-fcs-in-a-geodatabase-using-python/m-p/1289443#M67646</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;I am a beginner,&lt;BR /&gt;I'm not very good at English and I think it's hard to read.&lt;BR /&gt;I need a hint&lt;/PRE&gt;&lt;P&gt;I am new to Python but trying to rename hundreds of feature classes in a geodatabase.&lt;/P&gt;&lt;P&gt;This is the code I have been using that did not work so far:&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;arcpy.env.workspace = r'C:\Users\WK48.TOKYO\Desktop\ooamisi9_r\01_gdb\ooamisi9.gdb'&lt;/P&gt;&lt;P&gt;lstDatasets = arcpy.ListDatasets()&lt;BR /&gt;for dataset in lstDatasets:&lt;BR /&gt;lstFCs = arcpy.ListFeatureClasses("*", "", dataset)&lt;BR /&gt;for fc in lstFCs:&lt;BR /&gt;oldName = str(fc)&lt;BR /&gt;newName = oldName.replace("_FG_GML", "")&lt;BR /&gt;newName = newName.replace("_0001", "")&lt;BR /&gt;arcpy.Rename_management(fc, newName)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I wrote the above code&lt;BR /&gt;No change in database&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 02:57:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-fcs-in-a-geodatabase-using-python/m-p/1289443#M67646</guid>
      <dc:creator>taka</dc:creator>
      <dc:date>2023-05-16T02:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming FCs in a geodatabase using Python</title>
      <link>https://community.esri.com/t5/python-questions/renaming-fcs-in-a-geodatabase-using-python/m-p/1289505#M67647</link>
      <description>&lt;P&gt;ListFeatureclasses() returns a list of fc &lt;STRONG&gt;names&lt;/STRONG&gt;, but Rename expects complete &lt;STRONG&gt;paths&lt;/STRONG&gt;. You have to construct the path from the workspace and the fc name.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os

all_fc_names = arcpy.ListTables() + arcpy.ListFeatureClasses()
for ds in arcpy.ListDatasets():
    all_fc_names += arcpy.ListFeatureClasses(feature_dataset=ds)

for name in all_fc_names:
    fc_path = os.path.join(arcpy.env.workspace, name)
    new_name = name.replace("_FG_GML", "").replace("_0001", "")
    try:
        arcpy.management.Rename(old_path, new_name)
    except Exception as e:
        print("Could not rename " + name + ": " + str(e))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 08:51:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-fcs-in-a-geodatabase-using-python/m-p/1289505#M67647</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-05-16T08:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming FCs in a geodatabase using Python</title>
      <link>https://community.esri.com/t5/python-questions/renaming-fcs-in-a-geodatabase-using-python/m-p/1289928#M67659</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;It's been a wonderful day. &lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 02:39:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/renaming-fcs-in-a-geodatabase-using-python/m-p/1289928#M67659</guid>
      <dc:creator>taka</dc:creator>
      <dc:date>2023-05-17T02:39:20Z</dc:date>
    </item>
  </channel>
</rss>

