--- id: scantree version: "0.0.4" license: MIT license_treatment: permissive maintenance: active --- # scantree — Flexible recursive directory iterator: scandir meets glob("**", recursive=True) License: permissive · Maintenance: active · Downloads: 13.3M/mo ## What it is and what it does scantree is a recursive directory scanner that combines the functionality of os.scandir with glob-style pattern matching. It builds an in-memory representation of a file tree, allowing repeated access without re-scanning the filesystem. The library extends the standard os.DirEntry interface with additional path information (real paths, paths relative to the recursion root) and includes built-in detection and handling of cyclic symlinks. The package is typically used when you need flexible filtering of directory contents—such as matching files by wildcard patterns or custom predicates—while also needing efficient access to file metadata or the ability to traverse and aggregate information across the tree structure. It handles symlinks gracefully, distinguishing between regular symlinks and cycles that would otherwise cause infinite recursion. Use it for: - Find all files matching a pattern (e.g., '*.txt') across nested directories with relative and absolute path access - Build an in-memory representation of a directory tree for repeated queries without re-scanning the filesystem - Detect and safely handle cyclic symlinks during recursive directory traversal - Aggregate statistics or metadata across a file tree using the apply() method with custom file and directory handlers - Compare directory structures before and after filesystem operations using tree equality checks ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Recursively scans directories with flexible filtering, wildcard matching, and in-memory tree representation, providing extended file metadata and cyclic symlink detection. Yes. scantree is actively maintained, has no known vulnerabilities, minimal dependencies, and solves a real problem—flexible directory iteration with symlink safety and in-memory caching. Use it when you need pattern-based directory filtering or repeated tree access; skip it if you only need a single pass over the filesystem. ## Install pip install scantree uv add scantree poetry add scantree ## Installing scantree Before you install: Low friction: pure Python wheel with only two lightweight runtime dependencies (attrs and pathspec). Active maintenance with last commit on 2026-04-13 and latest release on 2024-08-03. License in practice: MIT license is permissive, allowing unrestricted use, modification, and distribution with minimal legal constraints. Quickstart: from scantree import scantree, RecursionFilter tree = scantree('/path/to/dir', RecursionFilter(match=['*.txt'])) print([path.relative for path in tree.filepaths()]) Verify before relying: - Performance characteristics when scanning very large directory trees or handling thousands of files - Memory overhead of the in-memory tree representation compared to streaming alternatives ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 13.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags recursive directory iterator, directory tree scanning, glob with filtering, wildcard path matching, symlink detection, file tree representation, directory traversal, filesystem, directory-scanning [View on SkillFed](https://skillfed.io/packages/scantree) · [View on PyPI](https://pypi.org/project/scantree/)