import os import os.path if __name__ =='__main__': root_dir='g:\\download' for root, dirs, files in os.walk(root_dir): for dir in dirs: print 'root=%s dir=%s' % (root,dir) #print 'root='+root+' dir='+dir for file in files: print 'root=%s file=%s' % (root,file) #print 'root='+root+' fie='+file