<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Merge layer files in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145954#M11382</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: 1em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #333333; background-color: rgba(248, 248, 248, 0.6);"&gt;Hello everyone,&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #333333; background-color: rgba(248, 248, 248, 0.6);"&gt;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.&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #333333; background-color: rgba(248, 248, 248, 0.6);"&gt;continuously to Xander&amp;nbsp; answer in &lt;A _jive_internal="true" href="https://community.esri.com/thread/120535" target="_blank"&gt;https://community.esri.com/thread/120535&lt;/A&gt;&amp;nbsp; , 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:&lt;SPAN style="color: black; font-size: 9pt !important; font-style: inherit; background-color: inherit; font-weight: inherit;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;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):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in fnmatch.filter(files, pattern):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr2merge.append(os.path.join(root, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter = counter + 1
arcpy.Merge_management(lyr2merge, r"C:\Project\layers\layer_total.lyr")
print 'merge'
print counter&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:58:17 GMT</pubDate>
    <dc:creator>Yaron_YosefCohen</dc:creator>
    <dc:date>2021-12-11T07:58:17Z</dc:date>
    <item>
      <title>Merge layer files</title>
      <link>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145954#M11382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: 1em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #333333; background-color: rgba(248, 248, 248, 0.6);"&gt;Hello everyone,&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #333333; background-color: rgba(248, 248, 248, 0.6);"&gt;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.&lt;/P&gt;&lt;P style="margin-bottom: 1em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #333333; background-color: rgba(248, 248, 248, 0.6);"&gt;continuously to Xander&amp;nbsp; answer in &lt;A _jive_internal="true" href="https://community.esri.com/thread/120535" target="_blank"&gt;https://community.esri.com/thread/120535&lt;/A&gt;&amp;nbsp; , 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:&lt;SPAN style="color: black; font-size: 9pt !important; font-style: inherit; background-color: inherit; font-weight: inherit;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;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):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in fnmatch.filter(files, pattern):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr2merge.append(os.path.join(root, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter = counter + 1
arcpy.Merge_management(lyr2merge, r"C:\Project\layers\layer_total.lyr")
print 'merge'
print counter&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:58:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145954#M11382</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2021-12-11T07:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Merge layer files</title>
      <link>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145955#M11383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the merge output use .shp instead of .lyr.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 09:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145955#M11383</guid>
      <dc:creator>KishorGhatage</dc:creator>
      <dc:date>2015-01-26T09:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Merge layer files</title>
      <link>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145956#M11384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;bbut then i have to convert shp to lyr file.&lt;/P&gt;&lt;P&gt;i want to skip this phase &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 09:26:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145956#M11384</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2015-01-26T09:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merge layer files</title>
      <link>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145957#M11385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gr peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 10:45:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-layer-files/m-p/145957#M11385</guid>
      <dc:creator>PeterVersteeg</dc:creator>
      <dc:date>2015-01-26T10:45:46Z</dc:date>
    </item>
  </channel>
</rss>

