I'm trying to automated a process of searching through folders and merging shapefiles of the same "type" (Roads, Water, Buildings)
On the surface, what I want to do seems pretty simple. I have several data sets in individual folders, each folder containing point, poly and line data for my study area.
The files in each folder are listed by map sheet, then description of the shape, then shape type. For example:
Each file folder contains a similar structure, only changing the map sheet name, but keeping the rest of the description. I want to join the files together based on the last 7 characters that make up their names. For example, each of the folders I am working with contain a building point file. (BL_POINT)
I've set up my script so it searches through all of my folders and lists the names of the files.
import arcpy, sys, os from arcpy import env arcpy.env.workspace = sys.path workspace = env.workspace feature_class =  walk = arcpy.da.Walk(workspace, datatype="FeatureClass", type="All") for dirpath, dirnames, filenames in walk: for filename in filenames: feature_class += filename + ";" print ("Found Feature Class: " + filename)
Are there any suggestions how I can automate the process of picking out files with identical final 7 characters once I add all my files to the feature_class list?
Ideally, I would like to have it so that it is automated, and does not require me to input the final 7 characters for each type of feature (Roads, Buildings, Water, etc)
Or, if I am going about this backwards, any suggestion of a better process would be swell.
Again, all I want to do is:
- Search through folders
- Merge files that are similar, based on their names.