Skip to content
Largo-mPublic

About

A powerful, chainable Python library for file discovery, management, automation, synchronization, and CLI workflows. A modern, developer-friendly toolkit built for efficient filesystem operations.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PathFlow

Elegant, chainable file automation for Python.

Find, filter, organize, synchronize, and manage files with a clean Python API and a powerful command-line interface.

Overview

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.

Features

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

Designed for practical automation

  • 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.

Installation

Requires Python 3.10 or newer.

Install the latest published version:

pip install pathflow-toolkit

Or install a specific version:

pip install pathflow-toolkit==0.1.2

Optional trash support:

pip install "pathflow-toolkit[trash]"

Quick Start

1. Find files

import path_file as pf

results = pf.find("~/Documents").files()

print("Found files:", results.count())

2. Filter files

results = (
    pf.find("~/Downloads")
    .files()
    .with_extension(".pdf")
    .larger_than("1MB")
    .older_than("30 days")
)

print(results.to_table())

3. Generate a report

report = pf.find("~/Documents").report()

print(report.to_table())

4. Preview file operations

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())

5. Execute an operation

After reviewing the preview, execute the operation with the required confirmation:

pf.find("~/Downloads") \
    .files() \
    .older_than("30 days") \
    .delete(confirm=True) \
    .execute()

6. Synchronize directories

syncer = pf.sync("~/Documents", "/backup/Documents")

syncer.direction("source_to_dest")
syncer.delete_extras(True)
syncer.progress()

diff = syncer.compare()
print(diff)

syncer.execute()

7. Use declarative rules

rules = pf.Rules.from_file("cleanup.toml")

rules.apply(
    pf.find("~/Downloads").files()
)

Command Line Interface

PathFlow includes a CLI for common file automation tasks.

Find files

pathflow find ~/Downloads --ext .jpg --larger 2MB

Generate reports

pathflow report ~/Documents --json

Copy files

pathflow copy ~/Photos /backup/Photos --ext .jpg --parallel 4

Delete files safely

pathflow delete ~/Temp --ext .tmp --confirm

Synchronize directories

pathflow sync ~/Documents /backup/Documents --delete-extras --dry-run

Find duplicates

pathflow duplicates ~/Photos

Create archives

pathflow archive ~/Projects -o backup.zip

Watch directories

pathflow watch ~/Downloads --filter "*.pdf" --on-new "notify.sh {}"

Apply automation rules

pathflow rules ~/Downloads -f cleanup.toml --apply

For all available commands and options:

pathflow --help

PathFlow vs. Standard Library

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

Documentation

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

Examples

The examples/ directory contains practical scripts covering:

  1. Cleaning old downloads
  2. Organizing photos
  3. Backing up documents
  4. Finding duplicate files
  5. Watching and sorting directories
  6. Synchronizing folders
  7. Declarative cleanup rules
  8. Compressing old files
  9. Batch renaming
  10. Generating audit reports

Development

Clone the repository:

git clone https://github.com/Largo-m/path-file.git
cd path-file

Create a virtual environment:

python -m venv .venv

Activate it on Windows:

.venv\Scripts\Activate.ps1

Activate it on Linux or macOS:

source .venv/bin/activate

Install development dependencies:

pip install -e ".[dev]"

Run tests:

pytest

Run tests with coverage:

pytest --cov=path_file --cov-report=term-missing

Run linting:

ruff check .

Run type checking:

mypy src/path_file

Contributing

Contributions, bug reports, feature suggestions, and improvements are welcome.

Please read CONTRIBUTING.md before submitting a pull request.

Security

If you discover a security vulnerability, please follow the instructions in SECURITY.md.

License

PathFlow is released under the MIT License. See LICENSE for details.


PathFlow

Less boilerplate. More automation.

Created and maintained by Largo-m.

GitHub Repository · PyPI Package

About

A powerful, chainable Python library for file discovery, management, automation, synchronization, and CLI workflows. A modern, developer-friendly toolkit built for efficient filesystem operations.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages