The Custom Sorter Program is a Python-based file organization tool designed to sort and manage images and text files into categorized folders based on user-defined configurations. It supports advanced features like resolution-based sorting, retry mechanisms for file operations, and cleaning up input folders.
- Sort by resolution: Categorizes files into user-defined resolution thresholds.
- Dynamic thresholds: Supports flexible sorting based on custom configurations.
- Organize in place or move: Choose whether to organize files within the input folder or move them to an output folder.
- Retry mechanism: Automatically retries file operations on failure.
- Post-processing cleanup: Removes empty folders from the input directory after processing.
- Python 3.8 or later
pip
(Python package manager)
- Clone or download the repository.
- Open a terminal and/or navigate to the project directory.
- cd custom_sorter
- Run the installer script:
- python install_cs.py
- The script will: Create a virtual environment (venv). Install the required dependencies from requirements.txt. Generate a batch file (cs_run.bat) for easier execution.
- Execute the batch file:
- cs.run.bat
This will:
- Activate the virtual environment.
- Run the custom_sorter.py script.
- Use the configuration specified in custom_sorter_config.yaml.
- Alternatively, run the script directly:
- python custom_sorter.py
The program reads settings from the custom_sorter_config.yaml file. Below is an example configuration:
- input_folders: List of folders to process.
- output_folder: Destination folder for sorted files.
- use_output_folder: Set to false to organize files within the input folder.
- resolution_folders: Define custom folder names and resolution thresholds.
- sort_method: resolution: Sort by image resolution.
- dynamic_thresholds: Automatically handle resolutions outside defined thresholds.
Categorize images based on:
Move or copy files while avoiding duplicates. Automatically retry failed operations.
Cleans up empty input folders. Compares input and output folders to remove duplicates.
Sample run organized input folder Sample run organized output folder
-
install_cs.py Sets up a virtual environment and installs dependencies. Creates a batch file for convenient execution.
-
custom_sorter.py Reads configurations and sorts files accordingly. Handles file operations and organizes them into structured folders.
-
custom_sorter_config.yaml User-defined settings for sorting logic and folder management.
-
post_processing_manager.py Removes duplicates from input folders based on the output folder. Cleans up empty folders.
-
cs_queue.py Manages file operations with retry mechanisms. Supports hash-based file comparison to avoid duplicates.
Listed in requirements.txt: pillow filelock psutil send2trash pyyaml
pip install -r requirements.txt
Common Issues Configuration Errors
Use YAML validators to check for syntax errors.
Close other programs that might lock the files. Run the script with elevated permissions if required.
Delete and recreate the venv folder: python install_cs.py
Add functionality to sort by orientation Add undo functionality to reverse file operations based on a log. Enhance configuration validation and error reporting.
Feel free to submit pull requests or report issues for improvements.
This project is open-source and available under the MIT License.