<?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 Re: Batch merge multiple shapefiles - with confusing file structure in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/batch-merge-multiple-shapefiles-with-confusing/m-p/20179#M723</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It can be done with python using &lt;/SPAN&gt;&lt;A href="http://docs.python.org/release/2.6.8/library/os.html?#os.listdir" rel="nofollow noopener noreferrer" target="_blank"&gt;os.listdir()&lt;/A&gt;&lt;SPAN&gt; to list the folders and &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000018000000" rel="nofollow noopener noreferrer" target="_blank"&gt;arcpy.ListFeatureClasses() &lt;/A&gt;&lt;SPAN&gt;to grab all the feature classes in the folder:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os

mainLoc = r"c:\testing"
outputLoc = r"c:\finalLocation\Output.gdb" #Note: ouput location should be outside the "testing" folder or additional runs will include any previously generated output
FCList = []

for dir in os.listdir(mainLoc):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = dir
&amp;nbsp;&amp;nbsp;&amp;nbsp; FCsubList = arcpy.ListFeatureClasses("*_CadastralPolygons.shp", "Polygon")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FCList.append(FCsubList)

arcpy.Merge_management(FCList, outputLoc)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 20:48:22 GMT</pubDate>
    <dc:creator>MattSayler</dc:creator>
    <dc:date>2021-12-10T20:48:22Z</dc:date>
    <item>
      <title>Batch merge multiple shapefiles - with confusing file structure</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/batch-merge-multiple-shapefiles-with-confusing/m-p/20178#M722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a series of folders that have different shapefiles in each one. The naming convention is odd. All I need to do is search through each subfolder and get the shapefiles ending with *_CadastralPolygons.shp. I figured I could output it to a holding folder for now (called "hold"). The naming convention doesnt matter either, I just need to get this working in my "testing" folder then I can apply it to my larger dataset.&amp;nbsp; Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;File Structure:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Dec 2013 16:36:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/batch-merge-multiple-shapefiles-with-confusing/m-p/20178#M722</guid>
      <dc:creator>NathanielClement</dc:creator>
      <dc:date>2013-12-24T16:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Batch merge multiple shapefiles - with confusing file structure</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/batch-merge-multiple-shapefiles-with-confusing/m-p/20179#M723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It can be done with python using &lt;/SPAN&gt;&lt;A href="http://docs.python.org/release/2.6.8/library/os.html?#os.listdir" rel="nofollow noopener noreferrer" target="_blank"&gt;os.listdir()&lt;/A&gt;&lt;SPAN&gt; to list the folders and &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000018000000" rel="nofollow noopener noreferrer" target="_blank"&gt;arcpy.ListFeatureClasses() &lt;/A&gt;&lt;SPAN&gt;to grab all the feature classes in the folder:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os

mainLoc = r"c:\testing"
outputLoc = r"c:\finalLocation\Output.gdb" #Note: ouput location should be outside the "testing" folder or additional runs will include any previously generated output
FCList = []

for dir in os.listdir(mainLoc):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = dir
&amp;nbsp;&amp;nbsp;&amp;nbsp; FCsubList = arcpy.ListFeatureClasses("*_CadastralPolygons.shp", "Polygon")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FCList.append(FCsubList)

arcpy.Merge_management(FCList, outputLoc)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:48:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/batch-merge-multiple-shapefiles-with-confusing/m-p/20179#M723</guid>
      <dc:creator>MattSayler</dc:creator>
      <dc:date>2021-12-10T20:48:22Z</dc:date>
    </item>
  </channel>
</rss>

