Skip to main content

Rule-based file sorting engine with pattern matching and dry run support

Project description

philiprehberger-file-organizer

Tests PyPI version License

Rule-based file sorting engine with pattern matching and dry run support.

Install

pip install philiprehberger-file-organizer

Usage

from philiprehberger_file_organizer import Organizer, Rule

organizer = Organizer(
    rules=[
        Rule(extensions=[".pdf", ".doc", ".docx"], destination="~/Documents"),
        Rule(extensions=[".jpg", ".png", ".gif"], destination="~/Pictures"),
        Rule(extensions=[".mp4", ".mkv"], destination="~/Videos"),
        Rule(pattern="invoice_*", destination="~/Documents/Invoices"),
    ]
)

# Preview what would happen (dry run)
report = organizer.preview("~/Downloads")
for action in report.actions:
    print(f"{action.source} -> {action.destination}")

# Execute
report = organizer.organize("~/Downloads")
print(f"Moved {report.total_moved} files ({report.total_size} bytes)")

# Undo
restored = Organizer.undo("~/Downloads")

Rule Options

Option Description
extensions Match by file extension
pattern Match by glob pattern
name_contains Match if filename contains string
larger_than Minimum file size in bytes
smaller_than Maximum file size in bytes
older_than_days Match files older than N days
newer_than_days Match files newer than N days
predicate Custom matching function

Conflict Resolution

organizer = Organizer(rules=rules, conflict="rename")   # default: adds (1), (2)...
organizer = Organizer(rules=rules, conflict="skip")      # skip existing
organizer = Organizer(rules=rules, conflict="overwrite")  # overwrite existing

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_file_organizer-0.1.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file philiprehberger_file_organizer-0.1.2.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_file_organizer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5d5d016917e347e9c0c57516ef9bbe7e8e2b166af63a48be6b126266b5c03141
MD5 c7daf03831a8dddfa16d8d7cce6fc396
BLAKE2b-256 949593e9cb6af59c83698ee69e895df942612e6c6104fed2cdfef8f511c254f8

See more details on using hashes here.

File details

Details for the file philiprehberger_file_organizer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_file_organizer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2fcb72ae10d4c3ee394c6bbddba0447fc2e4503aa9439d63fbfc2e30bd171815
MD5 449ba48cde54df71319028fa850b2b88
BLAKE2b-256 c287d2c20e06ab42c61f01e953b3281bbffd39d03b12c5dd6a08aae6294d60f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page