Skip to content

Instantly share code, notes, and snippets.

@IntegersOfK
Created July 8, 2016 14:32
Show Gist options
  • Save IntegersOfK/bc2f1109ffc04d78ace89b7a44ab8f3e to your computer and use it in GitHub Desktop.
Save IntegersOfK/bc2f1109ffc04d78ace89b7a44ab8f3e to your computer and use it in GitHub Desktop.
Simple python script to make a list of all the filenames in a particular folder tree.
import os
with open('output.txt', 'w') as a:
for path, subdirs, files in os.walk('/folder/with/files'):
for filename in files:
filestr = str(filename)
if filestr.endswith('.htm') or filestr.endswith('.html'):
print(filename)
a.write(str(filename) + ',') #separate by comma
else:
print('Skipping non html or htm file:' + filestr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment