Gettings subdirectories
Adonis
adonisv at DELETETHISTEXTearthlink.net
Wed May 3 20:49:49 EDT 2006
Florian Lindner wrote:
> Hello,
> how can I get all subdirectories of a given directories? os.listdir() gives
> me all entries and I've found no way to tell if an object is a file or a
> directory.
>
> Thanks,
>
> Florian
Here is a quick hack:
import os
import os.path
givenDir = "/"
listing = os.listdir(givenDir)
for item in listing:
joinPath = os.path.join(givenDir, item)
normPath = os.path.normpath(joinPath)
if os.path.isdir(normPath):
print normPath
More information about the Python-list
mailing list