Skip to content

Instantly share code, notes, and snippets.

@rabbleNaut
Created March 20, 2014 13:05
Show Gist options
  • Save rabbleNaut/9663326 to your computer and use it in GitHub Desktop.
Save rabbleNaut/9663326 to your computer and use it in GitHub Desktop.
Uses Arcpy to iterate through feature classes in a feature dataset and rename them.
import arcpy
from arcpy import *
env.workspace = r"C:\Users\RABBEY-C\RA_GIS\Projects\RA_EMST\Updated_Phase_Features.gdb\District_Unions"
fcList = arcpy.ListFeatureClasses()
#Renames featureclasses ending in "_Union" with ""
for fc in fcList:
Rename_management(fc, fc.replace('_Union',''))
@PandiyanKesavan
Copy link

PandiyanKesavan commented May 31, 2022

i have multiple datasets with multiple featureclasses . how can i loop through each dataset and perfome clip analysis on each dataset at the same time?

Name: Rename_Example2.py

Description: Rename fileGDB feature class

Import system modules

import arcpy
from arcpy import env

Set workspace

arcpy.env.workspace = "Folder Path of File Geodatabase"

wks = arcpy.ListWorkspaces('Name of the File Geodatabase to Select*','FileGDB')
print(wks)

for fgdb in wks:
arcpy.env.workspace = fgdb
fdta = arcpy.ListDatasets("*", "Feature")
print(fdta)
for dset in fdta:
for fc in arcpy.ListFeatureClasses(feature_dataset=dset):
print(fc)
arcpy.Rename_management(fc, fc+"_1",'FeatureClass')

print("Rename Complete")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment