how to proccess the blank in the path on linux

TheSaint fc14301589 at icqmail.com
Thu May 22 02:57:16 EDT 2008


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.





More information about the Python-list mailing list