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

Install using pip:

pip install unclutter-directory
  1. Change into the project directory:

    cd unclutter-directory
    
  2. 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.1.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.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unclutter_directory-0.9.1.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.1.tar.gz
Algorithm Hash digest
SHA256 c92ed80b464f2de7cd78f263e42ae30ef033ae305f1b819d303c9ef726e6c6b8
MD5 a79ad56619f87fdd9ede98a52197f429
BLAKE2b-256 a9cdaaeb941c39624758f37f3c697a8b12edacac174650387ecf4c27c28990c8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unclutter_directory-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 966fca9486396648204d43fbe62b16354311d3ea186a8f810ad6805622b2e4e1
MD5 bbe64ef95b9725204db4b0ba29fbd1f1
BLAKE2b-256 929e9a022444ee4799721d5d4a9839a896e2beab42a98b4929049dffa5333cdd

See more details on using hashes here.

Provenance

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