๐๏ธ files-sort
May 21, 2025 ยท View on GitHub
A powerful command-line tool to sort files in a directory based on criteria like file extension, size, or timestamps. Supports copying, moving, dry runs, verbose output, and automatic cleanup of empty directories.

๐ Features
- ๐ Sort by Extension: Groups files by file type (e.g.,
.jpg,.pdf). - ๐ฆ Sort by Size: Categorizes files into size buckets (e.g., 0โ1KB, 1โ100MB, etc.).
- ๐ Sort by Time: Uses modified time (
mtime) or created time (ctime) to group files by date. - ๐ Move or Copy: Choose whether to move or copy files.
- ๐ Dry Run Support: Simulate the process before applying any changes.
- ๐ฌ Interactive Prompts: Ask before overwriting or skipping conflicting files.
- ๐ Recursive Support: Process subdirectories.
โ Requirements
- Python 3.7+
colorama
Install dependencies:
pip install -r requirements.txt
or
pip install colorama
๐ฆ Installation
Option 1: Pip
Install via pip (if packaged as a CLI tool):
pip install -i https://test.pypi.org/simple/ --no-deps files-sort
To upgrade:
pip install --upgrade -i https://test.pypi.org/simple/ --no-deps files-sort
Option 2: Clone the repo
Clone the repo and make it executable:
git clone https://github.com/AfzGit/Files-Sort-py.git
cd Files-Sort-py/src/files_sort/
chmod +x files-sort.py
python files-sort.py -h
๐งฉ Usage
files-sort [OPTIONS] DIRECTORY
๐ง Options
| Option | Description |
|---|---|
-s, --sort | Sort by extension, size, mtime, or ctime. Default: extension. |
-c, --copy | Copy files instead of moving them. |
-v, --verbose | Show detailed logs during processing. |
-d, --dry | Simulate the sorting without actually moving/copying files. |
-f, --force | Skip confirmation prompts and overwrite existing files. |
-r, --recursive | Include subdirectories recursively. |
-u, --unique | List unique file extensions in the directory and exit. |
๐ Examples
๐ค Sort files by extension
files-sort ~/Downloads
๐ Sort by size (dry run + verbose)
files-sort -s size -d -v ~/Documents
๐ Sort by modified time (recursively)
files-sort -s mtime -r ~/Pictures
๐ Copy instead of move, force overwrite
files-sort -s extension -c -f ~/Videos
๐ See unique file extensions
files-sort -u ~/Downloads
๐งผ Auto Cleanup
If --recursive is used, the tool will also:
- Detect and optionally remove empty directories after sorting.
๐ Output Summary
At the end of execution, you'll see:
- Total files found
- Number of files moved or copied
- Number of files skipped
- Final categorization by folder