import arcpy, os out = r'Output\folder\location' # change this arcpy.env.workspace = r'Some\Path\Name' #change this shplist = arcpy.ListFeatureClasses('*.shp') arcpy.Merge_management(shplist, os.path.join(out, 'Merged_fc.shp')) print 'done'
Old thread, but helped me in Arc 10.2 with very little tweaking. Thanks a million, Caleb Mackey.
import arcpy, os, sys, traceback arcpy.env.overwriteOutput = True # Workspace for interchange files ws = r'C:\IGIC\Beginner\Unit_1\DATA\EffigyMounds\InterchangeFiles' arcpy.env.workspace = ws # Local Variables out = r'C:\IGIC\Beginner\Unit_1\DATA\EffigyMounds\Fire' try: # Creates a folder if it doesn't already exist if not os.path.exists(out): os.makedirs(out) # List all ArcInfo Interchange files (.e00) for cov in arcpy.ListFiles('*.e00'): arcpy.ImportFromE00_conversion(cov, ws, cov.split('.')[0]) print 'Converted %s' %cov # Exclude Interchange files and info folder for cov in arcpy.ListFiles(): if not '.e00' in cov and cov != 'info': arcpy.env.workspace = os.path.join(ws,cov) for fc in arcpy.ListFeatureClasses('*polygon'): arcpy.FeatureClassToFeatureClass_conversion(fc, out, '%s.shp' %cov) shp = os.path.join(out, '%s.shp' %cov) print 'Converted Coverage to %s' %shp # List shapefiles in folder to create input list for merge arcpy.env.workspace = out shplist = arcpy.ListFeatureClasses() arcpy.Merge_management(shplist, os.path.join(out, 'All_Fires.shp')) print 'done' except: # Get the traceback object tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + \ "\nError Info:\n" + str(sys.exc_info()[1]) msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n" arcpy.AddError(pymsg) arcpy.AddError(msgs) # Print Python error messages for use in Python / Python Window print pymsg + "\n" print msgs
import arcpy arcpy.env.workspace = "c:/junk/mergeMe" fcs = arcpy.ListFeatureClasses() arcpy.Merge_management(fcs, "Merged.shp")
import arcpy >>> arcpy.env.workspace = "D:eCognition Results/Landcover/Buildings" >>> Listing = arcpy.ListFeatureClasses() >>> arcpy.Merge_management(Listing,"MergedFile.shp") Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000735: Input Datasets: Value is required Failed to execute (Merge).