Skip to main content

Unclutter your directory with ease.

Project description

PyPI Version Python Versions Tests License

Unclutter Directory 🗂️

A smart file organization tool that automatically sorts your files and directories based on customizable rules.

Features ✨

  • Multi-Action Support

    • 🚚 Move files/directories to specific locations
    • 🗑️ Delete obsolete items
    • 📦 Compress files/directories to ZIP archives
    • 🔍 Search inside ZIP/RAR archives for matching files
  • Advanced Matching

    • Name patterns (starts/ends with, contains, regex)
    • File size thresholds (larger/smaller than)
    • Age conditions (older/newer than)
    • Directory-specific rules (is_directory flag)
    • Case-sensitive/insensitive matching
  • Safety & Control

    • 🧪 Dry-run simulation mode
    • 🔒 Interactive deletion prompts
    • 📝 Comprehensive logging

Installation 📦

pip install unclutter-directory

Usage 🚀

Basic Command Structure

unclutter organize [OPTIONS] TARGET_DIR [RULES_FILE]
unclutter validate [OPTIONS] RULES_FILE

Common Options

Option Description
--dry-run Simulate actions without making changes
--quiet Suppress non-error messages
--include-hidden Process hidden files/directories
--always-delete Skip confirmation for deletions
--never-delete Prevent all deletion actions

Example Workflow

  1. Create rules file (cleanup_rules.yaml):
- name: "Cleanup Old Downloads"
  conditions:
    older: "30d"
  action:
    type: delete

- name: "Organize Media Files"
  is_directory: false
  conditions:
    regex: "\.(mp4|mov|avi)$"
  action:
    type: move
    target: "media/"

- name: "Archive Projects"
  is_directory: true
  conditions:
    end: "_project"
    newer: "7d"
  action:
    type: compress
    target: "archives/"
  1. Run organization:
unclutter organize ~/Downloads cleanup_rules.yaml --dry-run

Apply changes:

unclutter organize ~/Downloads cleanup_rules.yaml

Rules Configuration ⚙️

Rule Structure

- name: "Rule Name"
  is_directory: false  # Optional (default: false)
  case_sensitive: false  # Optional (default: false)
  check_archive: true  # Optional (default: false)
  conditions:
    start: "report_"
    end: ".pdf"
    larger: "10MB"
    older: "2w"
  action:
    type: move
    target: "documents/"

Condition Types

Condition Format Examples
Time <number><unit> 30d, 2h, 15m
Size <number><unit> 500MB, 1GB, 100KB
Name String/Regex start: "temp_"

Time Units: s (seconds), m (minutes), h (hours), d (days), w (weeks)

Size Units: B, KB, MB, GB

Advanced Usage 🔧

Archive Handling

Search inside compressed files:

- name: "Find Secret Documents"
  check_archive: true
  conditions:
    regex: "top_secret.*\.docx$"
  action:
    type: move
    target: "classified/"

Directory Compression

- name: "Archive Old Projects"
  is_directory: true
  conditions:
    older: "6M"
  action:
    type: compress
    target: "project_archives/"

Development 👩💻

Project Setup

git clone https://github.com/zirition/unclutter-directory
cd unclutter-directory
python -m venv .venv
source .venv/bin/activate  # Linux/MacOS
# .venv\Scripts\activate  # Windows

pip install -e .[dev]  # Install with development dependencies

Testing

python -m unittest discover tests

License 📄

MIT License

Support 💬

For issues and feature requests, please open an issue.

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

unclutter_directory-0.9.4.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

unclutter_directory-0.9.4-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file unclutter_directory-0.9.4.tar.gz.

File metadata

  • Download URL: unclutter_directory-0.9.4.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for unclutter_directory-0.9.4.tar.gz
Algorithm Hash digest
SHA256 afff45ad95fa4572e5a8cc2960c0bbda92f683f42b51dbbc131ad0e0192efba4
MD5 6d14303d4cfa80a04775a3fd37c3673c
BLAKE2b-256 20ffa1c8f137cbe1a6b12ee30ea9903c7a7af7c66ad49cf78231a6bf93584ed2

See more details on using hashes here.

Provenance

The following attestation bundles were made for unclutter_directory-0.9.4.tar.gz:

Publisher: python-publish.yml on zirition/unclutter-directory

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unclutter_directory-0.9.4-py3-none-any.whl.

File metadata

File hashes

Hashes for unclutter_directory-0.9.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6f9cfdafe4212867ef844df28cd021bc32d78ec951a8864cba06079b4c40e8a7
MD5 f6b81d280415d19b977967bb97d10d18
BLAKE2b-256 414470c14d4a104d57f9c1b09910870c794ee90bfbf83c574ceacb56ab5db549

See more details on using hashes here.

Provenance

The following attestation bundles were made for unclutter_directory-0.9.4-py3-none-any.whl:

Publisher: python-publish.yml on zirition/unclutter-directory

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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