How To Do It Faster?!?
andrea.gavana at agip.it
andrea.gavana at agip.it
Thu Mar 31 06:38:34 EST 2005
Hello NG,
in my application, I use os.walk() to walk on a BIG directory. I need
to retrieve the files, in each sub-directory, that are owned by a
particular user. Noting that I am on Windows (2000 or XP), this is what I
do:
for root, dirs, files in os.walk(MyBIGDirectory):
a = os.popen("dir /q /-c /a-d " + root).read().split()
# Retrieve all files owners
user = a[18::20]
# Retrieve all the last modification dates & hours
date = a[15::20]
hours = a[16::20]
# Retrieve all the filenames
name = a[19::20]
# Retrieve all the files sizes
size = a[17::20]
# Loop throu all files owners to see if they belong
# to that particular owner (a string)
for util in user:
if util.find(owner) >= 0:
DO SOME PROCESSING
Does anyone know if there is a faster way to do this job?
Thanks to you all.
Andrea.
------------------------------------------------------------------------------------------------------------------------------------------
Message for the recipient only, if received in error, please notify the
sender and read http://www.eni.it/disclaimer/
More information about the Python-list
mailing list