I have a folder with around 50 .sde DB's. Within these .sde DB's there are around 450 feature classes which have been named to a certain standard. This standard has changed and I now need to update the feature class names.
The good part about the renaming is that I have to remove characters after the 3rd character up until the an '_'.
If anyone has any code available to help that would be great.
not tested or anything, also please don't do this straight into a PROD environment. Sure there's more efficient ways but will probably do the job.
I'd imagine you'd need to stop your services/locks etc also.
throw in Dan's replace statement for new_fc
import arcpy import os #folder containing all the .sde connection #files you want to rename FCs in sde_folder = r'D:\Downloads\tester' #list all items in directory and append #to sde_path list where .sde is in the #filename sde_paths =  dir_list = os.listdir(sde_folder) for item in dir_list: if '.sde' in item: sde_path = os.path.join(sde_folder, item) sde_paths.append(sde_path) #iterate over each .sde connection (EGDB) #and rename all your stuff for sde_path in sde_paths: arcpy.env.workspace = sde_path featureclasses = arcpy.ListFeatureClasses() for fc_old in featureclasses: fc_new = #try what Dan suggests arcpy.Rename_management(fc_old, fc_new)
Keep in mind that you'll probably need to connect as the owner of the table to rename it. Depending on how your database is organized, you may need to work out a way to reconnect as the appropriate user each time you encounter a new schema. I did something similar here that you can use for ideas.