import arcpy import os mainLoc = r"c:\testing" outputLoc = r"c:\finalLocation\Output.gdb" #Note: ouput location should be outside the "testing" folder or additional runs will include any previously generated output FCList = [] for dir in os.listdir(mainLoc): arcpy.env.workspace = dir FCsubList = arcpy.ListFeatureClasses("*_CadastralPolygons.shp", "Polygon") FCList.append(FCsubList) arcpy.Merge_management(FCList, outputLoc)