Skip to main content

PathFile

The elegant file automation library for Python.

PyPI Python Versions License CI Coverage


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:

  1. 01_clean_downloads.py - Clean old downloads
  2. 02_organize_photos.py - Organize photos by date
  3. 03_backup_documents.py - Backup with hash verification
  4. 04_find_duplicates.py - Find and report duplicates
  5. 05_watch_and_sort.py - Auto-sort downloads
  6. 06_sync_folders.py - Bidirectional sync
  7. 07_rules_declarative.py - Rules-based cleanup
  8. 08_compress_old_files.py - Compress old files
  9. 09_rename_batch.py - Batch rename photos
  10. 10_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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pathflow-toolkit 0.1.2
File Size Uploaded Provenance Actions
pathflow_toolkit-0.1.2.tar.gz 108.9 kB Without provenance Details for pathflow_toolkit-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pathflow-toolkit 0.1.2
File Interpreter ABI Platform Actions
pathflow_toolkit-0.1.2-py3-none-any.whl Python 3 none any Details for pathflow_toolkit-0.1.2-py3-none-any.whl

Total release size: 185.8 kB

Release files / pathflow_toolkit-0.1.2.tar.gz

Download URL pathflow_toolkit-0.1.2.tar.gz
Size 108.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b579cc74ce4da595060cca47d33fce4c180139e0ca487ab770e6399fc3242493
BLAKE2b-256 checksum
How to use checksums
3e6791b47efcb0b8da4f29d0800e8738dc8aa18c039df0b2603b88c45ac6df9e
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.2-py3-none-any.whl

Download URL pathflow_toolkit-0.1.2-py3-none-any.whl
Size 77.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d7947bee8fa7c7c4e4fae36b2ab919336ceadc377f7f8eb62bce0da504ce956
BLAKE2b-256 checksum
How to use checksums
12a453996384b37c464e5feb8b3bccf4ce5b2134fb5bfe340aa635bc83614d72
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.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page