import arcpy, os, sys # Set local variables outLocation = r'M:\TRIM\test.gdb\trim' emptyFC = 'troad' try: fcList = [] # All troad shp files in the workspace are placed into a list def fcs_in_workspace(workspace): arcpy.env.workspace = workspace for fc in arcpy.ListFeatureClasses('troad*'): fcList.append(os.path.join(workspace, fc)) for ws in arcpy.ListWorkspaces(): fcs_in_workspace(os.path.join(workspace, ws)) fcs_in_workspace(r'M:\104a\trim\shp') # Process: Append the feature classes into the empty feature class arcpy.Append_management(fcList, outLocation + os.sep + emptyFC, "NO_TEST") print fcList except: # If an error occurred while running a tool print the messages print arcpy.GetMessages()
fcString = "" for fc in fcList: fcString = fcString + fc + ";" arcpy.Append_management(fcString[:-1], outLocation + os.sep + emptyFC, "NO_TEST")
arcpy.Append_management(str(fcList).replace(",",";")[1:-1], outLocation + os.sep + emptyFC, "NO_TEST")
fcString = ";".join(fcList) arcpy.Append_management(fcString, outLocation + os.sep + emptyFC, "NO_TEST")