Unclutter your directory with ease.
Project description
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
.ziparchive.
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
-
Clone this repository:
git clone https://github.com/zirition/unclutter-directory.git
-
Change into the project directory:
cd unclutter-directory
-
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.yamlin<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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a6238d5a4e128ef2e6af30d03025cea5e6be41689a8a071d25f6d1be5fba08f
|
|
| MD5 |
1597a1604499e134208604bca48f27e6
|
|
| BLAKE2b-256 |
1b237bb5bd1d5174138bf19832e73c805c6141e9a7787789d54d05be22641cc6
|
Provenance
The following attestation bundles were made for unclutter_directory-0.9.0.tar.gz:
Publisher:
python-publish.yml on zirition/unclutter-directory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unclutter_directory-0.9.0.tar.gz -
Subject digest:
9a6238d5a4e128ef2e6af30d03025cea5e6be41689a8a071d25f6d1be5fba08f - Sigstore transparency entry: 163936172
- Sigstore integration time:
-
Permalink:
zirition/unclutter-directory@3ab6010ae38534ffad162a542286f552e1491fa4 -
Branch / Tag:
refs/tags/0.9.0 - Owner: https://github.com/zirition
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3ab6010ae38534ffad162a542286f552e1491fa4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file unclutter_directory-0.9.0-py3-none-any.whl.
File metadata
- Download URL: unclutter_directory-0.9.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
453acdc1aac8aaafa1dd80a785dcfa6be433ad9ba761ed0a7f6492f7275a8d0a
|
|
| MD5 |
405356072e635ac3297b5c3942d4f4e3
|
|
| BLAKE2b-256 |
a61acc50a40374e565f3105c7ca5a901151728f131f0b0170fa767b243f1f8d9
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unclutter_directory-0.9.0-py3-none-any.whl -
Subject digest:
453acdc1aac8aaafa1dd80a785dcfa6be433ad9ba761ed0a7f6492f7275a8d0a - Sigstore transparency entry: 163936173
- Sigstore integration time:
-
Permalink:
zirition/unclutter-directory@3ab6010ae38534ffad162a542286f552e1491fa4 -
Branch / Tag:
refs/tags/0.9.0 - Owner: https://github.com/zirition
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3ab6010ae38534ffad162a542286f552e1491fa4 -
Trigger Event:
release
-
Statement type: