I'm trying to convert all shapefiles into feature classes in my directory, including what's inside sub-folders. The code that I've compiled below (from reading previous answers and trial & error on my part) accomplishes this, but it seems that it also begins to iterate through the newly created GDB as well, which is bad. Any advice or insight would be greatly appreciated.
import arcpy from arcpy import env import os path = 'C:\\Data' env.workspace = path arcpy.management.CreateFileGDB(env.workspace,"Project","10.0") try: def fcs_in_workspace(workspace): env.workspace = workspace for fc in arcpy.ListFeatureClasses(): yield fc for ws in arcpy.ListWorkspaces(): for fc in fcs_in_workspace(os.path.join(workspace, ws)): yield fc OutGDB = env.workspace +'\\Project.gdb' for fc in fcs_in_workspace(env.workspace): arcpy.FeatureClassToGeodatabase_conversion(fc,OutGDB) print(fc +' copied.') except Exception as e: print(e) else: env.workspace = path arcpy.CompressFileGeodatabaseData_management(OutGDB) print(OutGDB + " has been compressed.")