public
Last active

A python script to recursively list all files in a given directory, newline separated

  • Download Gist
listall.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/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])

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.