How To Do It Faster?!?
Max Erickson
maxerickson at gmail.com
Thu Mar 31 09:58:48 EST 2005
I don't quite understand what your program is doing. The user=a[18::20]
looks really fragile/specific to a directory to me. Try something like
this:
>>> a=os.popen("dir /s /q /-c /a-d " + root).read().splitlines()
Should give you the dir output split into lines, for every file below
root(notice that I added '/s' to the dir command). There will be some
extra lines in a that aren't about specific files...
>>> a[0]
' Volume in drive C has no label.'
but the files should be there.
>>> len(a)
232
To get a list containing files owned by a specific user, do something
like:
>>> files=[line.split()[-1] for line in a if owner in line]
>>> len(files)
118
This is throwing away directory information, but using os.walk()
instead of the /s switch to dir should work, if you need it...
max
More information about the Python-list
mailing list