from pathlib import Path import re p = Path('/root/.hermes/wizard-outputs/spark/') found_files = list(p.rglob('test_todos.py')) print(f"Found files: {found_files}") for f in found_files: with open(f) as fh: for i, line in enumerate(fh, 1): print(f"Line {i}: {repr(line[:50])}")