posted: Mon, 02 Jul 2007 23:40 | filed under: / blog/ programming/ | permalink | Comments: 1
Well, it seems as though it's impossible to go through a life of coding without writing a directory lister... So in the great tradition of this site, I give you my directory lister -- It spits out the entirety of your directory structure, either starting at the current dir, or at some specified one. It spits it out in a format suitable for grepping on a Unix system, as for some reason, the Unix
lstool doesn't do so.
Here's the code in it's entirety -- written in python, under the terms of the GPLv2 or later
#!/usr/bin/env python import os import sys if len(sys.argv) == 1: k = "." else: k = sys.argv[1] for dr,drs,fls in os.walk(k): for i in fls: print dr+"/"+i for i in drs: print dr+"/"+i
May someone find it useful
