I want to get a list with just folders (without subfolders). Any idea how to do that ???
Sauronevileye 0 Newbie Poster
Recommended Answers
Jump to Postimport 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
All 4 Replies
jcao219 18 Posting Pro in Training
spiricn 0 Newbie Poster
hondros 25 Junior Poster
Sauronevileye 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.