Skip to main content

CLI tool for automatically sorting files into subfolders. Customisable with own rules with function to restore the old structure

Project description

Sortifile

Sortifile is a simple yet powerful command-line tool to automatically sort files in a directory into categorized subfolders based on customizable rules. It supports undo functionality to restore the original file structure, making file organization effortless and reversible.


Features

  • Automatically sort files by extension or custom rules
  • Supports recursive scanning of directories
  • Undo the last sorting operation to restore file locations
  • Dry-run mode to preview changes without moving files
  • Customizable rules via JSON configuration
  • Minimal dependencies, easy to install and use

Installation

Install via pip:

pip install sortifile

Or install from source:

git clone https://github.com/alphascg/sortifile.git
cd sortifile
pip install .

Usage

Basic usage:

sortifile /path/to/your/folder

Options

--dry-run, -d Show what would be moved without actually moving files

--silent, -s Suppress output messages during the operation

--config, -c Specify a custom JSON rules file (optional)

Undo last operation:

If you want to revert the last sorting operation:

sortifile undo

Configuration Rules

The rules file should be a JSON mapping of file extensions to target folders. This is what the default ruleset looks like:

{
  ".jpg": "Pictures",
  ".jpeg": "Pictures",
  ".png": "Pictures",
  ".gif": "Pictures",
  ".webp": "Pictures",
  ".bmp": "Pictures",
  ".tiff": "Pictures",
  ".svg": "Pictures",

  ".pdf": "Documents",
  ".doc": "Documents",
  ".docx": "Documents",
  ".odt": "Documents",
  ".rtf": "Documents",
  ".txt": "Documents",
  ".md": "Documents",

  ".xls": "Spreadsheets",
  ".xlsx": "Spreadsheets",
  ".ods": "Spreadsheets",
  ".csv": "Spreadsheets",

  ".ppt": "Presentations",
  ".pptx": "Presentations",
  ".odp": "Presentations",

  ".mp3": "Audio",
  ".wav": "Audio",
  ".flac": "Audio",
  ".aac": "Audio",
  ".ogg": "Audio",
  ".m4a": "Audio",

  ".mp4": "Video",
  ".avi": "Video",
  ".mkv": "Video",
  ".mov": "Video",
  ".wmv": "Video",
  ".flv": "Video",
  ".webm": "Video",

  ".zip": "Archives",
  ".rar": "Archives",
  ".7z": "Archives",
  ".tar": "Archives",
  ".gz": "Archives",
  ".bz2": "Archives",
  ".xz": "Archives",

  ".exe": "Programs",
  ".msi": "Programs",
  ".apk": "Programs",
  ".bat": "Programs",
  ".sh": "Programs",
  ".jar": "Programs",

  ".html": "Code",
  ".htm": "Code",
  ".css": "Code",
  ".js": "Code",
  ".ts": "Code",
  ".php": "Code",
  ".py": "Code",
  ".java": "Code",
  ".c": "Code",
  ".cpp": "Code",
  ".cs": "Code",
  ".rb": "Code",
  ".go": "Code",
  ".rs": "Code",
  ".json": "Code",
  ".xml": "Code",
  ".yml": "Code",
  ".yaml": "Code",

  ".iso": "Disk Images",
  ".img": "Disk Images",

  ".log": "Logs",
  
  ".properties": "Configuration",
  ".ini": "Configuration",
  ".cfg": "Configuration",
  ".conf": "Configuration"
}

If a file's extension is not found in the rules, it will be moved to an Others folder.

License

MIT License - see the LICENSE file for details.

Author

alphascg - GitHub

Contribute

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

Disclaimer

This tool is provided “as is” without warranty of any kind. Use at your own risk.

If you read the whole README, you are are breathtaking!

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

sortifile-1.2.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

sortifile-1.2.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file sortifile-1.2.0.tar.gz.

File metadata

  • Download URL: sortifile-1.2.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for sortifile-1.2.0.tar.gz
Algorithm Hash digest
SHA256 638f3822ff4f1290d9bd6715fba55ae54e5a263172626b5ba8671a106e01c889
MD5 4ac2c211c3f864c255cda300a0dd3c7e
BLAKE2b-256 8653623d63accdd214e5f9d62b9a0d05dace8718dbcf545a0698aa55eb4835df

See more details on using hashes here.

File details

Details for the file sortifile-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: sortifile-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for sortifile-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f4efe879bbddf10b7198dd90e6c149dc20ae7ea8a765b0be57b5f2c7b11ac8e
MD5 e010b4f21c8ed3844808fac53ad20caa
BLAKE2b-256 489e0a84f599ab6189424aadcc383d799376f398d0d984dfb1e3e37dfa92d656

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