Measured: 13 levels, an absolute path of 87 characters, read correctly with nothing missed and no errors.
So depth alone is not the problem. Two other things are:
| Real risk | Symptom | Prevention |
|---|---|---|
| Total path length | Legacy Windows APIs cap around 260 characters; beyond that, errors or truncation | Get alert around 200 characters; use long-path prefixes or shorter directory names |
| Symlinks and cycles | Traversal loops, or the same file processed twice | Track visited realpaths during traversal |
| Inconsistent permissions | One unreadable subdirectory aborts the whole walk | try/except per item and record unreadable paths as failures |
| Hidden and system directories | Counting .git and node_modules contents | State exclusion rules and report what was excluded |
Verifying nothing was missed
Do not trust 'done'. Cross-check with two independent numbers:
# count with the system's own walk find pdfs -type f -name '*.pdf' | wc -l # compare against the reported count # equal numbers, or it missed files
If find says 100 and the script says 98, finding those two and why they were skipped is the next task.
Wording that holds up
Walk every PDF under pdfs/, including subdirectories, up to 10 levels deep. Requirements: 1. Output the full relative path per file, not just the name — duplicate names across subdirectories are common. 2. Exclude .git and node_modules, and report how many were excluded. 3. On unreadable files or directories, record them as failures; do not abort the walk. 4. Final line: N files walked, X ok, Y failed.
Item 1 matters most: reporting only filenames will fool you when duplicates exist.