tags:

views:

52

answers:

1

Hi, simple script on a unix system (Mac) which seems to only return certain files True. Can't figure out why:

workdir = '/Volumes/place/sub place'

def myFunc(bla, dir, flist):
    for f in flist:
         print f, os.path.isfile(f)

os.path.walk(workdir,myFunc,None)

Returns:

tests.py False
utils.py False
utils.pyc False
writeXmlForMpgInPath.py False
.DS_Store True
Playout False
Playout Masters False
Projects False
ProRes Masters False
Source False
Sydney Playout Masters False
Web Preview False
.AU009644-M.xml.swp False
.DS_Store True
.DS_Store True
.DS_Store True
.DS_Store True
+3  A: 

You're using the function wrong:

workdir = '/Volumes/place/sub place'

def myFunc(_, dir, flist):
    for f in flist:
        fpath = os.path.join(dir, f) # need to make a full path first
        print f, fpath, os.path.isfile(fpath)

os.path.walk(workdir,myFunc,None)

see also os.walk, its nicer.

THC4k
thank you very much
Matt B