4
Contributors
4
Replies
7
Views
7 Years
Discussion Span
Last Post by Sauronevileye
0

Well you could always do something like this ..

def ListFolders(YOUR_PATH):
    for path i os.listdir( YOUR_PATH ):
        if not os.path.isfile( os.path.join( YOUR_PATH, path) ):
            yield path

That would get you a list of folders , without the files ..

Not really sure if that's what you wanted tho :\

Edited by spiricn: n/a

0
import os
for x in os.listdir(''):
    if os.path.isfile(x): pass
    else: print(x)

^ The above is for printing only folders.

import os
for x in os.listdir(''):
    print(x)

^ Above code is for printing all folders/files in the directory. No subdirectories

0
import os
for x in os.listdir(''):
    if os.path.isfile(x): pass
    else: print(x)

^ The above is for printing only folders.

import os
for x in os.listdir(''):
    print(x)

^ Above code is for printing all folders/files in the directory. No subdirectories

Thanx, worked as i wanted to. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.