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