Python
Рекурсивный обход файлов через pathlib
Поиск файлов по маске, фильтрация по размеру и подсчёт суммарного объёма.
Код
from pathlib import Path
def find_files(root, pattern="*.py", min_size=0):
"""Найти файлы по маске рекурсивно, пропуская служебные каталоги."""
skip = {".git", "__pycache__", "node_modules", ".venv"}
for path in Path(root).rglob(pattern):
if any(part in skip for part in path.parts):
continue
if path.is_file() and path.stat().st_size >= min_size:
yield path
files = list(find_files(".", "*.py"))
total = sum(f.stat().st_size for f in files)
print(f"Файлов: {len(files)}, объём: {total / 1024:.1f} КБ")