Listing 09-12: Directory tree being scrolled through

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 09\09.12 - Directory tree being scrolled through.py
# Description: Directory tree being scrolled through
##############################################################################

import os
import sys
for root, directories, files in os.walk(sys.argv[1]):
    print("\nPath:", root)
    for d in directories:
        print(f"  {d}/")
    for f in files:
        print(f"  {f}")
    print(f"{len(directories)} directory(s), {len(files)} file(s)")
Click here to download the file