summaryrefslogtreecommitdiff
path: root/misc/dirWalk.py
blob: 5fe8d9237a7061d670a9bde95cf2ca038ba60f5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#! /user/bin/env python3

# Chapter 9 Walk Directory with os.walk()

import os

for folderName, subfolders, filenames in os.walk(os.getcwd()):
    print('The current folder is: ' + folderName)

    for subfolder in subfolders:
        print('SUBFOLDER OF ' + folderName + ': ' + subfolder)

        for filename in filenames:
            print('FILE INSIDE ' + folderName + ': ' + filename)

        print('')