Skip to content

rglob

Lightweight recursive glob helpers for Python — find files, count lines, sum sizes.

This is a small labor-of-love package. Modern Python has pathlib.Path.rglob and tools like fd/ripgrep exist; rglob is small, easy to read, and ships with friendly helpers for the two things you usually want next: count lines and sum sizes.

Installation

pip install rglob

Quick start

import rglob

files = rglob.rglob("/path/to/project", "*.py")
files_cwd = rglob.rglob_("*.py")

lines = rglob.lcount(
    "/path/to/project",
    "*.py",
    lambda line: bool(line.strip()) and not line.lstrip().startswith("#"),
)

mb = rglob.tsize("/path/to/photos", "*.jpg", rglob.megabytes)

The full modern API (find / find_all with filter flags) is described on the API page. For the command-line, see CLI. For design context, see Architecture and the decisions log.

Where to go next