Skip to content

Instantly share code, notes, and snippets.

@jdan
Created January 13, 2012 03:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdan/1604413 to your computer and use it in GitHub Desktop.
Save jdan/1604413 to your computer and use it in GitHub Desktop.
A python script to recursively list all files in a given directory, newline separated
#!/usr/bin/python
import os
import sys
def listdir(d):
if not os.path.isdir(d):
print d
else:
for item in os.listdir(d):
listdir((d + '/' + item) if d != '/' else '/' + item)
if __name__ == '__main__':
if len(sys.argv) < 2:
print 'Usage: listall DIR'
else:
listdir(sys.argv[1])
@treystout
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment