arcpy.Merge_management(Listing,"MergedFile.shp") Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Datasets: Dataset campus_ortho.tiles.tile00.v5.shp;campus_ortho.tiles.tile01.v8.shp;campus_ortho.tiles.tile02.v5.shp;campus_ortho.tiles.tile03.v6.shp;campus_ortho.tiles.tile04.v5.shp;campus_ortho.tiles.tile05.v9.shp;campus_ortho.tiles.tile06.v9.shp;campus_ortho.tiles.tile07.v9.shp;campus_ortho.tiles.tile08.v10.shp;campus_ortho.tiles.tile09.v8.shp;campus_ortho.tiles.tile10.v8.shp;campus_ortho.tiles.tile11.v8.shp;campus_ortho.tiles.tile12.v8.shp;campus_ortho.tiles.tile13.v9.shp;campus_ortho.tiles.tile14.v9.shp;campus_ortho.tiles.tile15.v8.shp;campus_ortho.tiles.tile17.v8.shp;campus_ortho.tiles.tile18.v9.shp does not exist or is not supported Failed to execute (Merge). >>>
import arcpy, os arcpy.env.workspace = "D:/eCognition Results/Landcover/Buildings" for file in arcpy.ListFiles('*.shp'): os.rename(os.path.join(ws,file), os.path.join(ws,file.replace('.','_')[:-4] + '.shp')) Listing = arcpy.ListFeatureClasses() arcpy.Merge_management(Listing,"MergedFile.shp")
Caleb,
I went and renamed the files by hand and it worked like a charm. Thanks for the help. Now I just have to get the rename code to work so I don't have to do them all by hand.
import arcpy, os arcpy.env.workspace = "D:/eCognition Results/Landcover/Buildings" for file in arcpy.ListFeatureClasses(): os.rename(os.path.join(ws,file), os.path.join(ws,file.replace('.','_')[:-4] + '.shp')) Listing = arcpy.ListFeatureClasses() arcpy.Merge_management(Listing,"MergedFile.shp")
import arcpy, os ws = "D:/eCognition Results/Landcover/Buildings" arcpy.env.workspace = ws out = "D:/eCognition Results/Landcover/Buildings/Outputs" for file in arcpy.ListFeatureClasses(): arcpy.CopyFeatures_management(file, os.path.join(out,file.replace('.','_')[:-4] + '.shp')) arcpy.env.workspace = out Listing = arcpy.ListFeatureClasses() arcpy.Merge_management(Listing,"MergedFile.shp")
I tried the first one and the logic seems to make sense to me but I get an 'exeptions.NameError'>: name 'ws' is not defined' So I am looking over the rename function to see what those parameters are all about. Can't be far from it now. Again man thanks for all the help.
import arcpy, os ws = "D:/eCognition Results/Landcover/Buildings" arcpy.env.workspace = ws for file in arcpy.ListFeatureClasses(): os.rename(os.path.join(ws,file), os.path.join(ws,file.replace('.','_')[:-4] + '.shp')) Listing = arcpy.ListFeatureClasses() arcpy.Merge_management(Listing,"MergedFile.shp")
Works!
Only thing is that it only renames the .shp files and none of the associated files (.dbf,.prj, ect.) so the merge gives an error saying it cannot be completed probably because it cannot see the associated filetypes. However, I assume that I can just rewrite this for each of the filetypes and once they are all renamed the merge should work as expected? Fingers crossed.
import arcpy, os ws = "D:/eCognition Results/Landcover/Buildings" arcpy.env.workspace = ws out = "D:/eCognition Results/Landcover/Buildings/Outputs" for file in arcpy.ListFeatureClasses(): arcpy.CopyFeatures_management(file, os.path.join(out,file.replace('.','_')[:-4] + '.shp')) arcpy.env.workspace = out Listing = arcpy.ListFeatureClasses() arcpy.Merge_management(Listing,"MergedFile.shp")