On 22:26, mercoledì 21 maggio 2008 zhf wrote:
> I want ro walk a directory and its sub directory on linux
os.path.walk() should do the job.
Recursively you should try this, which I found on some web site:
8<---------8<---------8<---------8<---------8<---------8<---------
def file_find(folder, fname):
"""search for a filename fname starting in folder"""
for root, dirs, files in os.walk(folder):
for file in files:
# make search case insensitive
if fname.lower() == file.lower():
return Path.join(root, fname)
8<---------8<---------8<---------8<---------8<---------8<--------
Definitely I don't know about path with spaces or Unicode file names.
--
http://mail.python.org/mailman/listinfo/python-list