title: Concatenating files of different directories to one file (Python)
body: <p>so I have managed to concatenate every single .txt file of one directory into one file with this code:</p>
  <pre><code>import os
  import glob
  
  folder_path = &quot;/Users/EnronSpam/enron1/ham&quot;
  for filename in glob.glob(os.path.join(folder_path, '*.txt')):
    with open(filename, 'r', encoding=&quot;latin-1&quot;) as f:
        text = f.read()
        with open('new.txt', 'a') as a:
              a.write(text)
  </code></pre>
  <p>but in my 'EnronSpam' folder there are actually multiple directories (enron 1-6), each of which has a ham directory. How is it possible to go through each directory and add every single file of that directory into one file?</p>