Hello everyone,
I try to merge layer files that spread in big folder that divided to a lot of sub folders. all the layer files as different names.
continuously to Xander answer in https://community.esri.com/thread/120535 , how do i chagne this code so i will can merge all the layer files ? i tried this code but it doesn't work out:
import arcpy,os,sys,string,fnmatch import arcpy.mapping from arcpy import env rootPath = r"C:\Project\layers" pattern = '*.lyr' lyr2merge = [] counter = 0 for root, dirs, files in os.walk(rootPath): for filename in fnmatch.filter(files, pattern): lyr2merge.append(os.path.join(root, filename)) counter = counter + 1 arcpy.Merge_management(lyr2merge, r"C:\Project\layers\layer_total.lyr") print 'merge' print counter
In the merge output use .shp instead of .lyr.
bbut then i have to convert shp to lyr file.
i want to skip this phase
Looking at the merge tool i think the output will by .shp even with lyr input. perhaps what you could do is make a script that selects all features from one layer and copy past it to the other feature. In arcmap this works
gr peter