how to get files in a directory

Anand K Rayudu ary at
Wed Sep 29 16:55:48 CEST 2004

Hi all,

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

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,

More information about the Python-list mailing list