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

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.2.tar.gz (13.8 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.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unclutter_directory-0.9.2.tar.gz
  • Upload date:
  • Size: 13.8 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.2.tar.gz
Algorithm Hash digest
SHA256 02601ea774d69f3547aad6fb80615216807e620d650d78f51e041f6455ef522f
MD5 814bd11c71cc85ce7c6a57fa5dcb4c6e
BLAKE2b-256 22e448ba8c012dc238533134a1af8601ee45389eb463af83c1ee0f25061668e6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for unclutter_directory-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 55491beb248f280a8550305ba553e4939b9c718ee92e14f149ec0f8ddbcb1dc4
MD5 2f0caa3ba0274c5c233b63d282cc659a
BLAKE2b-256 647d4169a5e44bedaca964aecc997dbe1cbe5f0d92e67a8147865e7c5fe7c097

See more details on using hashes here.

Provenance

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