Skip to content
MyDSHMy DSH Field Notes
中文
Independently maintained; not affiliated with DeepSeek. No association with mydsh.dev or other MyDSH sites.

Home/Workspace & files/Batches & deep folders

Deep directories: 13 levels still read fine, but paths get long

Deeply nested project directories; worried about missing deep files or hitting path length limits.

VerifiedVersion and environmentChecked 2026-11-14
Tool
Python 3.13 with pymupdf
Sample
13 levels of nesting with one PDF at the bottom
Checked
2026-11-14

Copyable command

find pdfs -type f -name '*.pdf' | wc -l

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 riskSymptomPrevention
Total path lengthLegacy Windows APIs cap around 260 characters; beyond that, errors or truncationGet alert around 200 characters; use long-path prefixes or shorter directory names
Symlinks and cyclesTraversal loops, or the same file processed twiceTrack visited realpaths during traversal
Inconsistent permissionsOne unreadable subdirectory aborts the whole walktry/except per item and record unreadable paths as failures
Hidden and system directoriesCounting .git and node_modules contentsState 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.

There is a hidden cost too: the longer the path, the more path noise dilutes what the model sees. For deep trees, copy into a flat temporary directory first.

What counts as working

Check every line. All of them pass or the job is not done.

  • find's count equals the script's count
  • Outputs show relative paths, not bare filenames
  • Exclusions are explicitly reported

Where it fails

Symptom, cause, what to do — written in the order it actually happens.

SymptomCauseWhat to do
Long-path error on WindowsTotal length exceeds the legacy API limitShorten intermediate names, or enable long-path support
Traversal hangsA symlink cycleTrack visited realpaths

Sources

Verified means measured here. Compiled means every line carries a source.