Skip to content

Instantly share code, notes, and snippets.

@glennhefley
Created January 3, 2024 11:51
Show Gist options
  • Save glennhefley/08a7cc0d65acdd81d1dffd56f23ceacd to your computer and use it in GitHub Desktop.
Save glennhefley/08a7cc0d65acdd81d1dffd56f23ceacd to your computer and use it in GitHub Desktop.
A ConCat in Python
#I need a python script that will cat
#all of the *.html files in a single level directory
# into one file: newfile.html
import glob
import shutil
html_files = glob.glob('*.html')
with open('newfile.html', 'wb') as outfile:
for filename in html_files:
if filename == 'newfile.html':
# don't want to copy the output into the output
continue
with open(filename, 'rb') as readfile:
shutil.copyfileobj(readfile, outfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment