Hello,
I have been working on a Python script that will go into multiple sub folders of the main folder and puts all the files with the same name in a list, and then merge them together. Everything works until the Merge_management tool, i get the following error:
Traceback (most recent call last):
File "H:\Python\Practice\Sidra Scripts\test.py", line 31, in <module>
arcpy.Merge_management(fencePoList, outputName)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 3124, in Merge
raise e
ExecuteError: Failed to execute. Parameters are not valid.
The script is:
import arcpy
import os
from arcpy import env
arcpy.overwriteoutput = 1
inputFolder= "H:\\Python\\Practice\\SampleData\\\Survey_data"
targetFileName= "H:\\Python\\Practice\\SampleData\\Survey_data\\Merged_Posts.shp"
# Create the empty list
fencePoList= []
#try:
for root, dirs, files in os.walk(inputFolder, topdown=True):
for filename in files:
if filename[-6]=="P":
#print os.path.join(root, filename)
fencePosts = str(os.path.join(root, filename))
fencePoList.append(fencePosts)
# Format the list of shapefiles properly for the merge tool
#mergeSHP = '"'+';'.join(fencePoList)+'"'
#print mergeSHP
# Determine the new output feature class path and name
outputName = os.path.join(inputFolder, "Merged_Posts.shp")
#Merging the fence_pole files in all the folders
print "starting merge"
arcpy.Merge_management(fencePoList, outputName)
print "ending merge"
arcpy.AddMessage(arcpy.GetMessages())
#except Exception, ErrorDesc:
#If an error set output boolean parameter "Error" to True.
# arcpy.AddError(str(ErrorDesc))
# row = None
# rows = None
Hope someone can help!
Thanks