Skip to main content

A Python CLI tool to sort files by their extension

Project description

๐Ÿ”€ file-ext-sorter

PyPI version Python versions License

A command-line tool that groups files into folders based on their file extensions.

Organize messy download folders, group media by type, quickly analyze and find files by type or archive project files โ€” all with a single command.

Main Features

  • ๐Ÿ”€ Automatic file grouping by file extensions:
    • ๐Ÿ— Handles duplicate names and naming conflicts
    • ๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ Supports dry-run mode for safe preview
  • ๐Ÿš€ Asynchronous performance
  • ๐ŸŽ’ Minimal and portable: no databases, no external frameworks
  • ๐Ÿ Compatible with Python 3.8-3.14+
  • ๐Ÿ“ฆ PyPI: install globally and use as a CLI command

Project showcase image


๐Ÿ“ฆ Installation

Requires: Python 3.8+
Dependencies: aiofiles, aioshutil, colorama, tomli

Install from PyPI:

pip install file-ext-sorter

๐Ÿš€ Usage

file-ext-sorter <source_dir> <output_dir> [--dry-run] [--debug]

Optional flags:

  • --dry-run: show what would be done without actually copying files
  • --debug: verbose debug output

It will:

  1. Scan the source folder for all files (recursively).
  2. Group them into subfolders based on their extensions (e.g., .jpg, .mp4, .zip, .etc.)
  3. Copy them into subfolders within the output directory, grouped by extension.

Note: This tool copies files by default to preserve the original source directory. No files are deleted or moved.

๐Ÿ’ก Example

Source folder files state:

source/
โ”œโ”€โ”€ image.png
โ”œโ”€โ”€ doc.txt
โ”œโ”€โ”€ archive.zip
โ””โ”€โ”€ video.mp4

Use file-ext-sorter tool:

file-ext-sorter ./source ./output

After running file-ext-sorter:

output/
โ”œโ”€โ”€ png/
โ”‚   โ””โ”€โ”€ image.png
โ”œโ”€โ”€ txt/
โ”‚   โ””โ”€โ”€ doc.txt
โ”œโ”€โ”€ zip/
โ”‚   โ””โ”€โ”€ archive.zip
โ””โ”€โ”€ mp4/
    โ””โ”€โ”€ video.mp4

๐Ÿ†˜ Command Help

Run this to see available options:

file-ext-sorter --help
Click to expand help output
 
๐Ÿ”€ FILE SORTER

Sort and organize your files by extension

v0.1.0

This CLI tool scans a source directory and copies files into subfolders in the output directory based on file extensions.

Notes on terminology:
  duplicate - file with the same file name and content (skipped from copying)
  conflict - file with the same file name and different content (resolved by new name)

Usage:    file-ext-sorter <source> <output>
Example:  file-ext-sorter ./path/to/source/folder ./path/to/output/folder

Positional arguments:
  source  folder to scan and sort files from (should exist)
  output  folder to sort files into (may not exist)

Options:
  -h, --help  show this help message and exit
  --dry-run   preview the scan and sort result without copying any files.
  --debug     enable debug logging to console
  --version   show the version number and exit

โŒ Uninstall

To remove the tool from your system:

pip uninstall file-ext-sorter

๐Ÿ“ท App Screenshots

1. Help menu (--help)

help menu screenshot

2. Run on sample files

normal run screenshot

3. Dry-run mode (preview the scan and sort result without actual files copying)

dry-run screenshot

๐Ÿ› Report Issues

Found a bug or want to request a feature?

Please visit the GitHub Issues page.

๐Ÿ’ก Contributing

Ideas, bugs, or feature requests? Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.

โš–๏ธ License

MIT โ€” see LICENSE.

๐Ÿ™ Acknowledgements

Special thanks to the following open-source libraries:

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

file_ext_sorter-0.1.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

file_ext_sorter-0.1.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file file_ext_sorter-0.1.0.tar.gz.

File metadata

  • Download URL: file_ext_sorter-0.1.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for file_ext_sorter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bb800851f5e33714a9bdcaeb9b76ae94b9d8ed98b3a2cd57821d671eafd7c8c5
MD5 f98f7d038ecd2d1850c10ca448126a7c
BLAKE2b-256 59df00a775dd5e887279ca0c23234d148b5afe0c17709dca82a3097bd508a673

See more details on using hashes here.

File details

Details for the file file_ext_sorter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for file_ext_sorter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6390a1fd94219981c4a695304eb82a015974813cf37a4ae14b0c33c38fbee7a0
MD5 0e2623cb27252468fe69ad748a793326
BLAKE2b-256 f0d11b2c92bb0bc78130e058c16ec807c5b48ee717b64bb0f15a9048171dafa7

See more details on using hashes here.

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