Skip to main content
Added language tag
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84
import os, sys, arcpy

BaseFolder = r'c:\your\folder' # change this to match your 'top level' folder

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,os.path.join(BaseFolder,'AllTheLots.shp'))
import os, sys, arcpy

BaseFolder = r'c:\your\folder' # change this to match your 'top level' folder

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,os.path.join(BaseFolder,'AllTheLots.shp'))
import os, sys, arcpy

BaseFolder   = sys.argv[1]
OutShapefile = sys.argv[2]

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,OutShapefile)
import os, sys, arcpy

BaseFolder   = sys.argv[1]
OutShapefile = sys.argv[2]

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,OutShapefile)
import os, sys, arcpy

BaseFolder = r'c:\your\folder' # change this to match your 'top level' folder

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,os.path.join(BaseFolder,'AllTheLots.shp'))
import os, sys, arcpy

BaseFolder   = sys.argv[1]
OutShapefile = sys.argv[2]

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,OutShapefile)
import os, sys, arcpy

BaseFolder = r'c:\your\folder' # change this to match your 'top level' folder

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,os.path.join(BaseFolder,'AllTheLots.shp'))
import os, sys, arcpy

BaseFolder   = sys.argv[1]
OutShapefile = sys.argv[2]

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,OutShapefile)
Source Link
Michael Stimson
  • 25.7k
  • 2
  • 35
  • 75

This is probably a good place to start learning python. Here is a little script that will do what you want:

import os, sys, arcpy

BaseFolder = r'c:\your\folder' # change this to match your 'top level' folder

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,os.path.join(BaseFolder,'AllTheLots.shp'))

Copy and paste into notepad, save with an extension of .py and then add it to a toolbox.

If you want to be able to specify the input base folder and output shape only a few small changes are needed:

import os, sys, arcpy

BaseFolder   = sys.argv[1]
OutShapefile = sys.argv[2]

ListOfLotsToMerge = [] # an empty list

# walk the folders and databases from basefolder down
# but only polygon feature classes
for Path, Folders, FeatureClasses in arcpy.da.Walk(BaseFolder,datatype='FeatureClass',type='Polygon'):
    for ThisFC in FeatureClasses:
        if ThisFC.lower() == 'lot': # does this feature class have the right name?
            # add the full path to this feature class to the list
            ListOfLotsToMerge.append(os.path.join(Path,ThisFC))

# merge them all into a single shapefile called AllTheLots in your base folder 
arcpy.Merge_management(ListOfLotsToMerge,OutShapefile)

When adding this script tool it needs two parameters, the first is a folder type the second is a feature class (or shapefile) type.