how to get files in a directory

Anand K Rayudu ary at esi-group.com
Wed Sep 29 10:55:48 EDT 2004


Hi all,

I am trying to find a way to get the files recursively in a given 
directory,

The following code is failing, can some one please suggest what could be 
problem here


from os import walk,join

for root,dir,files in os.walk("E:\myDir1\MyDir2"):
   for i in dir:
       for j in files:
           fille = root+i+j
            print file

Surprisingly if i give os.walk("E:\myDir1") the above code works, but 
not if i have 2 levels of directories.

Thanks & Best Regards,
Anand





More information about the Python-list mailing list