Find, filter, organize, synchronize, and manage files with a clean Python API and a powerful command-line interface.
Python's built-in pathlib and shutil are excellent tools, but handling complex file operations often requires repetitive code, nested loops, and custom filtering logic.
PathFlow makes file automation simple.
It provides a fluent, chainable API that lets you describe what you want to do instead of manually implementing every step.
import path_file as pf
pf.find("~/Downloads") \
.files() \
.with_extension(".jpg") \
.larger_than("2MB") \
.older_than("30 days") \
.move_to("~/Pictures/OldLarge") \
.execute()One readable pipeline. Multiple file operations. No unnecessary boilerplate.
| Feature | Description |
|---|---|
| Chainable API | Build readable file-processing pipelines |
| 40+ Filters | Filter by name, extension, size, date, content, permissions, and more |
| Safe Operations | Preview destructive operations with dry-run support |
| Parallel Execution | Run supported operations using multiple workers |
| Duplicate Detection | Identify duplicate files using hashes and names |
| Rich Reporting | Generate readable tables and structured reports |
| Directory Sync | Synchronize directories with hash-based verification |
| Folder Watching | Monitor directories for filesystem changes |
| Rules Engine | Define reusable automation rules using TOML |
| Archive Management | Create and extract archives |
| Full CLI | Use PathFlow directly from your terminal |
| Type Hints | Better IDE support and static type checking |
- Readable: Express complex operations through simple method chains.
- Predictable: Preview operations before making destructive changes.
- Lightweight: Core functionality uses the Python standard library.
- Extensible: Optional integrations are available when needed.
- Developer-friendly: Type hints, structured output, and a dedicated CLI.
Requires Python 3.10 or newer.
Install the latest published version:
pip install pathflow-toolkitOr install a specific version:
pip install pathflow-toolkit==0.1.2Optional trash support:
pip install "pathflow-toolkit[trash]"import path_file as pf
results = pf.find("~/Documents").files()
print("Found files:", results.count())results = (
pf.find("~/Downloads")
.files()
.with_extension(".pdf")
.larger_than("1MB")
.older_than("30 days")
)
print(results.to_table())report = pf.find("~/Documents").report()
print(report.to_table())PathFlow supports dry-run workflows so you can inspect an operation before applying it.
result = (
pf.find("~/Downloads")
.files()
.older_than("30 days")
.delete(dry_run=True)
.execute()
)
print(result.summary())After reviewing the preview, execute the operation with the required confirmation:
pf.find("~/Downloads") \
.files() \
.older_than("30 days") \
.delete(confirm=True) \
.execute()syncer = pf.sync("~/Documents", "/backup/Documents")
syncer.direction("source_to_dest")
syncer.delete_extras(True)
syncer.progress()
diff = syncer.compare()
print(diff)
syncer.execute()rules = pf.Rules.from_file("cleanup.toml")
rules.apply(
pf.find("~/Downloads").files()
)PathFlow includes a CLI for common file automation tasks.
pathflow find ~/Downloads --ext .jpg --larger 2MBpathflow report ~/Documents --jsonpathflow copy ~/Photos /backup/Photos --ext .jpg --parallel 4pathflow delete ~/Temp --ext .tmp --confirmpathflow sync ~/Documents /backup/Documents --delete-extras --dry-runpathflow duplicates ~/Photospathflow archive ~/Projects -o backup.zippathflow watch ~/Downloads --filter "*.pdf" --on-new "notify.sh {}"pathflow rules ~/Downloads -f cleanup.toml --applyFor all available commands and options:
pathflow --help| Capability | pathlib | shutil | PathFlow |
|---|---|---|---|
| Chainable operations | — | — | Yes |
| Bulk file filtering | Manual | Limited | Yes |
| Dry-run workflows | Manual | — | Yes |
| Duplicate detection | Manual | — | Yes |
| Progress reporting | Manual | — | Yes |
| Parallel execution | Manual | — | Yes |
| Content search | Manual | — | Yes |
| Declarative rules | — | — | Yes |
| Directory synchronization | — | Limited | Yes |
| Command-line interface | — | — | Yes |
| Type hints | Yes | Partial | Yes |
Explore the project documentation:
| Resource | Description |
|---|---|
| Quick Start | Get started with PathFlow |
| API Reference | Explore the Python API |
| CLI Reference | Learn all CLI commands |
| Recipes | Practical automation examples |
| Rules Engine | Build TOML-based workflows |
| Publishing Guide | Package and release instructions |
| Changelog | Version history |
The examples/ directory contains practical scripts covering:
- Cleaning old downloads
- Organizing photos
- Backing up documents
- Finding duplicate files
- Watching and sorting directories
- Synchronizing folders
- Declarative cleanup rules
- Compressing old files
- Batch renaming
- Generating audit reports
Clone the repository:
git clone https://github.com/Largo-m/path-file.git
cd path-fileCreate a virtual environment:
python -m venv .venvActivate it on Windows:
.venv\Scripts\Activate.ps1Activate it on Linux or macOS:
source .venv/bin/activateInstall development dependencies:
pip install -e ".[dev]"Run tests:
pytestRun tests with coverage:
pytest --cov=path_file --cov-report=term-missingRun linting:
ruff check .Run type checking:
mypy src/path_fileContributions, bug reports, feature suggestions, and improvements are welcome.
Please read CONTRIBUTING.md before submitting a pull request.
If you discover a security vulnerability, please follow the instructions in SECURITY.md.
PathFlow is released under the MIT License. See LICENSE for details.