<?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 Need some Python to add a suffix of _OLD to all features in enterprise geodatabase in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/need-some-python-to-add-a-suffix-of-old-to-all/m-p/1542983#M72945</link>
    <description>&lt;P&gt;I need to rename up to 100 features which are a mixture of tables &amp;amp; poly's &amp;amp; lines to add the suffix _OLD, &amp;amp; then _NEW &amp;amp; then to remove the suffix altogether as part of renaming of features when importing new data.&lt;/P&gt;&lt;P&gt;I've had a go at some code but get the attached error - any ideas?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Set the workspace to your enterprise geodatabase
arcpy.env.workspace = "Path to SDE"

# List all feature classes and tables in the geodatabase
datasets = arcpy.ListFeatureClasses() + arcpy.ListTables()

# Loop through each dataset and rename it
for dataset in datasets:
    new_name = f"{dataset}_OLD"
    arcpy.management.Rename(dataset, new_name)

print("All items have been renamed with the suffix '_OLD'.")
Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 12, in &amp;lt;module&amp;gt;
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 7253, in Rename
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 7250, in Rename
    retval = convertArcObjectToPythonObject(gp.Rename_management(*gp_fixargs((in_data, out_data, data_type), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 520, in &amp;lt;lambda&amp;gt;
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 160068: The dataset name is invalid.
Failed to execute (Rename).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Sep 2024 10:44:19 GMT</pubDate>
    <dc:creator>AndrewReynoldsDevon</dc:creator>
    <dc:date>2024-09-26T10:44:19Z</dc:date>
    <item>
      <title>Need some Python to add a suffix of _OLD to all features in enterprise geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/need-some-python-to-add-a-suffix-of-old-to-all/m-p/1542983#M72945</link>
      <description>&lt;P&gt;I need to rename up to 100 features which are a mixture of tables &amp;amp; poly's &amp;amp; lines to add the suffix _OLD, &amp;amp; then _NEW &amp;amp; then to remove the suffix altogether as part of renaming of features when importing new data.&lt;/P&gt;&lt;P&gt;I've had a go at some code but get the attached error - any ideas?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Set the workspace to your enterprise geodatabase
arcpy.env.workspace = "Path to SDE"

# List all feature classes and tables in the geodatabase
datasets = arcpy.ListFeatureClasses() + arcpy.ListTables()

# Loop through each dataset and rename it
for dataset in datasets:
    new_name = f"{dataset}_OLD"
    arcpy.management.Rename(dataset, new_name)

print("All items have been renamed with the suffix '_OLD'.")
Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 12, in &amp;lt;module&amp;gt;
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 7253, in Rename
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 7250, in Rename
    retval = convertArcObjectToPythonObject(gp.Rename_management(*gp_fixargs((in_data, out_data, data_type), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 520, in &amp;lt;lambda&amp;gt;
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 160068: The dataset name is invalid.
Failed to execute (Rename).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 10:44:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-some-python-to-add-a-suffix-of-old-to-all/m-p/1542983#M72945</guid>
      <dc:creator>AndrewReynoldsDevon</dc:creator>
      <dc:date>2024-09-26T10:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need some Python to add a suffix of _OLD to all features in enterprise geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/need-some-python-to-add-a-suffix-of-old-to-all/m-p/1543001#M72946</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/551141"&gt;@AndrewReynoldsDevon&lt;/a&gt;&amp;nbsp;I would add a print statement to see which feature class it's failing on:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# Loop through each dataset and rename it
for dataset in datasets:
    print(f"Renaming {dataset}")
    new_name = f"{dataset}_OLD"
    arcpy.management.Rename(dataset, new_name)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Sep 2024 13:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/need-some-python-to-add-a-suffix-of-old-to-all/m-p/1543001#M72946</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-09-26T13:00:54Z</dc:date>
    </item>
  </channel>
</rss>

