You can loop through all of the feature classes and append the values for field HUC_8 to a list. You can then loop through the list to apply the query and copy/append to the new feature class. Ex:import arcpy, os
from arcpy import env
env.overwriteOutput = 1
list = []
# append all HUC_8 values to list
def getHUC_8():
env.workspace = r"G:\ChrisGIS\Events_Editor0806"
lstGDBs = arcpy.ListWorkspaces("*", "FileGDB")
for gdb in lstGDBs:
env.workspace = gdb
for fc in arcpy.ListFeatureClasses("Events2HEM"):
rows = arcpy.SearchCursor(fc, "", "", "HUC_8")
for row in rows:
list.append(row.HUC_8)
getHUC_8()
# remove duplicates from list
list = dict.fromkeys(list)
list = list.keys()
env.workspace = r"G:\ChrisGIS\Events_Editor0806"
lstGDBs = arcpy.ListWorkspaces("*", "FileGDB")
for gdb in lstGDBs:
env.workspace = gdb
for n in list:
for fc in arcpy.ListFeatureClasses("Events2HEM"):
arcpy.MakeFeatureLayer_management(fc, "fc_lyr", "HUC_8 = " + str(n))
env.workspace = r"G:\ChrisGIS\HUC_8" + os.sep + str(n) + ".gdb"
if arcpy.Exists("Events2HEM"):
arcpy.Append_management("fc_lyr", "Events2HEM", "NO_TEST")
else:
arcpy.FeatureClassToFeatureClass_conversion("fc_lyr", env.workspace, "Events2HEM")
env.workspace = gdb