scantree
Flexible recursive directory iterator: scandir meets glob("**", recursive=True)
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
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 · maintenance · safety
MIT (permissive) — MIT license is permissive, allowing unrestricted use, modification, and distribution with minimal legal constraints.
last release 2024-08-03 (741 days) · last repo commit 2026-04-13 · 16 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 13,323,146 downloads/mo, #1,286 on PyPI
Alternatives
Verify before relying
from scantree import scantree, RecursionFilter
tree = scantree('/path/to/dir', RecursionFilter(match=['*.txt']))
print([path.relative for path in tree.filepaths()])- 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
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 on this page. Verify before relying on it.
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
scantree on PyPI
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 the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesattrspathspec |
| Maintenance | Actively maintained 741 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 13,323,146 / month, #1,286 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: scantree-0.0.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “recursive directory iterator”
- scantreeRecursively scans directories with flexible filtering, wildcard…
- rignoreProvides fast directory traversal with support for .gitignore rules…
- asyncinotifyProvides async and sync Python bindings to Linux inotify for…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also ignore-python · scandir · wcmatch · glob2 · pathmagic · globmatch · colcon-recursive-crawl · xdg-base-dirs · pathtools · path.py