Skip to content

Instantly share code, notes, and snippets.

@monkeyxite
Created January 29, 2014 08:06
Show Gist options
  • Save monkeyxite/8683681 to your computer and use it in GitHub Desktop.
Save monkeyxite/8683681 to your computer and use it in GitHub Desktop.
import os
def list_files(startpath):
for root, dirs, files in os.walk(startpath):
level = root.replace(startpath, '').count(os.sep)
indent = ' ' * 4 * (level)
print('{}{}/'.format(indent, os.path.basename(root)))
subindent = ' ' * 4 * (level + 1)
for f in files:
print('{}{}'.format(subindent, f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment