xsnippet logotype

xsnippet

#362691, Untitled [ Python 3 ]

by Guest
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import os

def list_files(startpath):
    for root, dirs, files in os.walk(startpath):
        level = root.replace(startpath, '').count(os.sep)
        indent = ' ' * 4 * (level)
        print('{}{}/'.format(indent, os.path.basename(root)))
        subindent = ' ' * 4 * (level + 1)
        for f in files:
            print('{}{}'.format(subindent, f))

list_files('D:/fe-lab-6-materials/Design')