PathFile
The elegant file automation library for Python.
Why PathFile?
Python's pathlib is great for single-file operations but painful for bulk operations, filtering, searching, and reporting. shutil has inconsistent APIs. Users end up writing 50-line scripts for tasks that should be 1 line.
PathFile bridges this gap with a chainable, declarative, dry-run-safe API.
# Before: 30 lines of pathlib + shutil + os.walk
# After: 1 line with path_file
import path_file as pf
pf.find("~/Downloads").files().with_extension(".jpg").larger_than("2MB").older_than(
"30 days"
).move_to("~/Pictures/OldLarge").execute()
Features
- 🔗 Chainable API - Fluent interface for complex operations
- 🛡️ Dry-run by default - Safety first for destructive operations
- 📦 Zero dependencies - Only Python standard library
- 🎯 40+ filters - Size, time, name, path, content, duplicates, permissions
- ⚡ 19 registered actions - Copy, move, delete, trash, archive, extract, compress, hash, rename, touch, chmod, read/write, symlink, and more
- 📊 Rich reporting - Tables, JSON, CSV, summary statistics
- 🔄 Parallel execution - Multi-threaded with progress bars
- 📝 Declarative rules - TOML-based automation rules
- 👀 Folder watching - Polling-based file monitoring
- 🔁 Directory sync - Hash-based bidirectional synchronization
- 🖥️ Full CLI - 12 commands for terminal use
- 🏷️ Full type hints - Strict mypy compliance, IDE autocomplete
Installation
pip install path-file
Requires Python 3.10+
Quick Start
import path_file as pf
# Find and report
report = pf.find("~/Documents").report()
print(report.to_table())
# Batch operations with safety (preview first)
result = pf.find("~/Downloads").files().older_than("30 days").delete(dry_run=True).execute()
print(result.summary())
# Actually delete (requires confirmation)
pf.find("~/Downloads") \
.files() \
.older_than("30 days") \
.delete(confirm=True) \
.execute()
# Organize photos by date
pf.find("~/Photos") \
.files() \
.with_extensions(".jpg", ".png", ".heic") \
.for_each(lambda e: e.path.rename(f"~/Photos/Organized/{e.modified:%Y/%m}/{e.name}"))
# Sync with verification
syncer = pf.sync("~/Documents", "/backup/Documents")
syncer.direction("source_to_dest").delete_extras(True).progress()
diff = syncer.compare()
syncer.execute()
# Declarative rules
rules = pf.Rules.from_file("cleanup.toml")
rules.apply(pf.find("~/Downloads").files())
Documentation
CLI Usage
# Find files
path-file find ~/Downloads --ext .jpg --larger 2MB
# Generate report
path-file report ~/Documents --json
# Copy with progress
path-file copy ~/Photos /backup/Photos --ext .jpg --parallel 4
# Safe delete (requires --confirm)
path-file delete ~/Temp --ext .tmp --confirm
# Sync directories
path-file sync ~/Documents /backup/Documents --delete-extras --dry-run
# Find duplicates
path-file duplicates ~/Photos
# Archive
path-file archive ~/Projects -o backup.zip
# Watch folder
path-file watch ~/Downloads --filter "*.pdf" --on-new "notify.sh {}"
# Apply rules
path-file rules ~/Downloads -f cleanup.toml --apply
Comparison
| Feature | pathlib | shutil | path_file |
|---|---|---|---|
| Chainable API | ❌ | ❌ | ✅ |
| Bulk filtering | Manual | Limited | ✅ 40+ filters |
| Dry-run safety | Manual | ❌ | ✅ Default |
| Progress bars | ❌ | ❌ | ✅ Built-in |
| Parallel execution | Manual | ❌ | ✅ Built-in |
| Content search | Manual | ❌ | ✅ Text & regex |
| Duplicate detection | Manual | ❌ | ✅ By hash/name |
| Declarative rules | ❌ | ❌ | ✅ TOML |
| Folder watching | ❌ | ❌ | ✅ Polling |
| Directory sync | ❌ | Manual | ✅ Hash-based |
| CLI | ❌ | ❌ | ✅ 12 commands |
| Zero dependencies | ✅ | ✅ | ✅ |
| Type hints | ✅ | Partial | ✅ Strict |
Examples
See examples/ for 10 real-world scripts:
01_clean_downloads.py- Clean old downloads02_organize_photos.py- Organize photos by date03_backup_documents.py- Backup with hash verification04_find_duplicates.py- Find and report duplicates05_watch_and_sort.py- Auto-sort downloads06_sync_folders.py- Bidirectional sync07_rules_declarative.py- Rules-based cleanup08_compress_old_files.py- Compress old files09_rename_batch.py- Batch rename photos10_report_audit.py- Generate audit reports
Contributing
See CONTRIBUTING.md for development setup and guidelines.
License
MIT License - see LICENSE for details.
Security
See SECURITY.md for security policy and vulnerability reporting.
Changelog
See CHANGELOG.md for release history.
Made with ❤️ by Largo-m
Metadata
Release files for pathflow-toolkit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pathflow_toolkit-0.1.0.tar.gz | 108.9 kB | Without provenance | Details for pathflow_toolkit-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pathflow_toolkit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pathflow_toolkit-0.1.0-py3-none-any.whl |
Total release size: 185.9 kB
Release files / pathflow_toolkit-0.1.0.tar.gz
| Download URL | pathflow_toolkit-0.1.0.tar.gz |
|---|---|
| Size | 108.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4825bc3bc767c667acb4973c42a16ed411fecbbfddd38e92f6053742ec1d17d6
|
|
BLAKE2b-256 checksum How to use checksums |
55aba3f3a220cd78b16d3d62998c04ac6fcf0b4ec743f9c34d20992686a3c551
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / pathflow_toolkit-0.1.0-py3-none-any.whl
| Download URL | pathflow_toolkit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 77.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20cf7ad3ff6d224f0b529a91dbd1f3742e4bcc81ef2ade9b4605f37fd2aad0fd
|
|
BLAKE2b-256 checksum How to use checksums |
804dbf6d315a9043a2415748e13774de4779e209739c17dd6e85ff8782cb93d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Security for pathflow-toolkit 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.