Answers for "list all files and directories in subdirectories in py"

1

get list of all files in folder and subfolders python

for path, subdirs, files in os.walk(root):
    for name in files:
        print os.path.join(path, name)
Posted by: Guest on December-07-2020
2

python list directories only

>>> [ name for name in os.listdir(thedir) if os.path.isdir(os.path.join(thedir, name)) ]
['ctypes', 'distutils', 'encodings', 'lib-tk', 'config', 'idlelib', 'xml', 'bsddb', 'hotshot', 'logging', 'doc', 'test', 'compiler', 'curses', 'site-packages', 'email', 'sqlite3', 'lib-dynload', 'wsgiref', 'plat-linux2', 'plat-mac']
Posted by: Guest on August-21-2020

Code answers related to "list all files and directories in subdirectories in py"

Browse Popular Code Answers by Language