Skip to content

Instantly share code, notes, and snippets.

@tonjadwyer
Last active February 7, 2019 19:43
Show Gist options
  • Save tonjadwyer/8c6a88c8fd9a981ac14c64cd0bb25421 to your computer and use it in GitHub Desktop.
Save tonjadwyer/8c6a88c8fd9a981ac14c64cd0bb25421 to your computer and use it in GitHub Desktop.
python walk directory to list (thispointer.com)
# puts all file paths in filelist
# puts all folders in dirlist
filelist = []
dirlist = []
for (dirpath,dirnames,filenames) in os.walk('my\path\to\walk'):
filelist += [os.path.join(dirpath,file) for file in filenames]
dirlist += dirnames
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment