I need to merge certain shapefiles with a specific name in sub directories. I can do the merge but where I am stuck on is including each shapefile specific root path to each shapefile 'Path' field before the merge. I have the following.
rootpath will like below, Shapefile.shp will always be the same
C:\Tem\blah\2020 blah\Case1\Shapefile.shp
C:\Tem\blah\2020 blah\Case2\Shapefile.shp
C:\Tem\blah\2020 blah\Notice\Shapefile.shp
C:\Tem\blah\2020 blah\Use\Shapefile.shp
rootPath = r'C:\Temo\blah\2020 blah' # different folders aftre this
counter = 0
matches = []
for root, dirs, files in os.walk(rootPath):
for filename in files:
if filename == "shapefile.shp":
match = ( os.path.join(root, filename))
matches.append (match)
counter = counter + 1
arcpy.Merge_management(matches, r"C:\Temp\MergedTest.shp")