os.walk: Get entire path

Miki Tebeka miki.tebeka at zoran.com
Mon Aug 30 17:28:49 EDT 2004


Hello Florian,

> 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.
from os.path import join, abspath
from os import walk

for root, dirs, files in walk("somedir"):
    for file in files:
        print abspath(join(root, file))

HTH.
--
------------------------------------------------------------------------
Miki Tebeka <miki.tebeka at zoran.com>
http://tebeka.spymac.net
The only difference between children and adults is the price of the toys



More information about the Python-list mailing list