I'm trying to merge content from different TXT files by using Python, but the challenge is I need to only merge content from the same file names coming from different folders. Here's a screenshot for your reference:
So far, I can print out all the file names with their full paths:
import os
for root, dirs, files in os.walk(".", topdown=False):
for file in files:
if file.endswith(".txt"):
filepath = os.path.join(root, file)
print (filepath)
However, how could I use Python to only merge files with the same name...still researching. Let me know if you know the answer, or point me a way to research more. Thank you very much and happy holidays!