In a folder I have a group of file geodatabases that have unique names from one another. Within each geodatabase is a polyline feature class that is not uniquely named - they are all called 'Elev_Contour'. I want to use Python to iterate through the geodatabases and append the geodatabase name onto the end of the feature class names to make them unique. After that is complete, I want to copy the feature classes into one new geodatabase.
I've used da.walk to build a list of all the feature classes, but I am struggling with how to access just the geodatabase name when iteratively renaming the feature classes.
import os
import arcpy
from arcpy import env
env.workspace = r"b:\contours"
fclist = []
for dirpath, dirnames, filenames in arcpy.da.Walk(env.workspace,datatype="FeatureClass"):
for filename in filenames:
fclist.append(os.path.join(dirpath, filename))
for fc in fclist:
print fc
b:\contours\Elev_321168_Albany_E_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321169_Albany_W_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321240_Binghamton_E_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321241_Binghamton_W_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321259_Boston_W_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321278_Buffalo_E_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321279_Buffalo_W_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321420_Elmira_E_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321421_Elmira_W_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321482_Glens_Falls_E_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321483_Glens_Falls_W_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321516_Harrisburg_E_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321517_Harrisburg_W_1X1.gdb\Elevation\Elev_Contour
b:\contours\Elev_321600_Kingston_E_1X1.gdb\Elevation\Elev_Contour