I have a database that are in file folders and in databases (gdb format). It looks a bit like this
Main File folder
So the names of the folders and the gdb’s are unique but the featuresclass in each gdb have the same name (not the same factor).
What I want is a script that search for all featureclasses J, K and L and rename them. So far I have:
from arcpy import env
# Set the workspace for the ListFeatureClass function
- arcpy.env.workspace = r"D: \GIS\ZONE1\ZONE1_007.gdb"
# Use the ListFeatureClasses function to return a list of all FC.
fclist = arcpy.ListFeatureClasses("*","ALL")
# Rename FC
for fc in fclist:
if fc == "TEKST_XX01P_point":
arcpy.Rename_management("TEKST_XX01P_point ", "P_XX01_house")
elif fc == " TEKST_XX032_area ":
This works for only gdb set in my workspace. Can anyone help me with the code I need to search also the folders. I was looking at the da.walk function but this is not working for me:
workspace = D: \GIS "
feature_classes = 
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace,
for filename in filenames:
thank you greeting peter