Created
January 13, 2012 03:19
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://docs.python.org/library/os.html#os.walk