From 75a42ec54dbf721caa659ddf02c1f46fc2cb4bef Mon Sep 17 00:00:00 2001 From: mlot Date: Fri, 6 Jun 2025 13:40:57 -0400 Subject: initial commit for archiving --- misc/dirWalk.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 misc/dirWalk.py (limited to 'misc/dirWalk.py') diff --git a/misc/dirWalk.py b/misc/dirWalk.py new file mode 100644 index 0000000..5fe8d92 --- /dev/null +++ b/misc/dirWalk.py @@ -0,0 +1,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('') + -- cgit