Advertisement
here2share

# count_files.py

Mar 10th, 2025
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. # count_files.py
  2.  
  3. import os
  4. from tkinter.filedialog import askdirectory
  5.  
  6. def count_files():
  7.     PATH = askdirectory()
  8.     dirCount = 0
  9.  
  10.     for root, dirs, files in os.walk(PATH):
  11.         print('Looking in:', root)
  12.         dirCount += len(dirs)
  13.         print('Number of files:', len(files))
  14.    
  15.     print('Number of Directories:', dirCount)
  16.  
  17. count_files()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement