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.
- 📄 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.
- Python 3.7+
colorama
Install dependencies:
pip install -r requirements.txtor
pip install coloramaInstall via pip (if packaged as a CLI tool):
pip install -i https://test.pypi.org/simple/ --no-deps files-sortTo upgrade:
pip install --upgrade -i https://test.pypi.org/simple/ --no-deps files-sortClone 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 -hfiles-sort [OPTIONS] DIRECTORY| 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. |
files-sort ~/Downloadsfiles-sort -s size -d -v ~/Documentsfiles-sort -s mtime -r ~/Picturesfiles-sort -s extension -c -f ~/Videosfiles-sort -u ~/DownloadsIf --recursive is used, the tool will also:
- Detect and optionally remove empty directories after sorting.
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
