Skip to main content

Unclutter your directory with ease.

Project description

Tests

Unclutter Directory

Unclutter Directory is a Python-based tool for organizing files in a directory according to specified rules. It allows you to move, delete, or compress files based on file conditions such as name patterns, size, and age.

The rules are defined in a YAML file used as a parameter.

Features

  • Move: Move files to a specified directory.
  • Delete: Permanently remove files.
  • Compress: Compress files into a .zip archive.

Using

  • Customizable Rules: Define conditions like name patterns, file size, and age for performing actions.
  • Dry Run Mode: Simulate actions without making actual changes to verify intended effect.
  • Support for Hidden Files: Option to include hidden files (files starting with a dot).
  • Flexible Deletion Options: Choose to always delete matched files or never delete them.

Requirements

Installation

  1. Clone this repository:

    git clone https://github.com/zirition/unclutter-directory.git
    
  2. Change into the project directory:

    cd unclutter-directory
    
  3. Install dependencies:

    uv sync
    

Usage

Command-Line Interface

The project includes a CLI utility powered by Click. You can run the tool using the following commands.

Organize

Organize files in a directory based on your rules:

python -m unclutter-directory organize <target_dir> [<rules_file>] [--dry-run] [--quiet] [--always-delete] [--never-delete] [--include-hidden]
  • <target_dir>: Directory path where the files are to be organized.
  • <rules_file>: Path to the YAML file containing organization rules. If omitted, it searches for .unclutter_rules.yaml in <target_dir>.
  • --dry-run: Optional flag for simulating the actions without making changes.
  • --quiet: Optional flag to suppress non-error messages.
  • --always-delete: Optional flag to always delete matched files without confirmation.
  • --never-delete: Optional flag to never delete matched files.
  • --include-hidden: Optional flag to include hidden files (files starting with a dot).

Validate

Validate the structure and attributes of a rules file:

python -m unclutter-directory validate <rules_file>
  • <rules_file>: Path to the YAML file that contains organization rules.

Rules File

Define rules in a YAML file. Here is an example:

- name: "Process STL Files"
  conditions:
    end: ".stl"
  action:
    type: "move"
    target: "stl_files/"
  check_archive: true

- name: "Process ISO Files"
  conditions:
    end: ".iso"
    older: "2d"
  action:
    type: "move"
    target: "iso_files/"
  check_archive: true

The file example_rules.yaml contains in the first rule all the options.

The rules are processed in order, the first rule that is a match is the rule used, so put first the more specific ones.

Testing

Run the unit tests to verify functionality:

python -m unittest discover tests

Contributing

Contributions are welcome!

License

This project is licensed under the MIT License.

Contact

You can reach me at owner of the repo AT owner of the repo DOT com

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.0.tar.gz (14.9 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.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for unclutter_directory-0.9.0.tar.gz
Algorithm Hash digest
SHA256 9a6238d5a4e128ef2e6af30d03025cea5e6be41689a8a071d25f6d1be5fba08f
MD5 1597a1604499e134208604bca48f27e6
BLAKE2b-256 1b237bb5bd1d5174138bf19832e73c805c6141e9a7787789d54d05be22641cc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for unclutter_directory-0.9.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for unclutter_directory-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 453acdc1aac8aaafa1dd80a785dcfa6be433ad9ba761ed0a7f6492f7275a8d0a
MD5 405356072e635ac3297b5c3942d4f4e3
BLAKE2b-256 a61acc50a40374e565f3105c7ca5a901151728f131f0b0170fa767b243f1f8d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for unclutter_directory-0.9.0-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