os.walk: Get entire path

Steve Holden sholden at holdenweb.com
Mon Aug 30 08:11:37 EDT 2004


Tom B. wrote:

> "Florian Lindner" <Florian.Lindner at xgm.de> wrote in message
> news:cgssom$hu6$00$1 at news.t-online.com...
> 
>>Hello,
>>when I'm walking through a file system hierarchy using os.walk, how can I
>>get the full path of a file or dir? normpath and abspath don't work.
>>Thx,
>>Florian
> 
> 
> I would use glob
> 
> import glob
> 
> glob.glob('c:\\images\\*\\*.jpg')
> 
> yields all .jpg's in //images and sub directories with full path in a list.

No, it doesn't.

If the directory hierarchy is more thane one level deep you won't see 
those files, and neither (I believe without verifying) will you see 
files from the top-level directory itself.

regards
  Steve



More information about the Python-list mailing list