Skip to content

Repository files navigation

prefix-file-sort

Python License Platform CI

A smart file grouping tool that automatically organizes files into folders based on their filename prefixes. Perfect for sorting TV series episodes, numbered documents, or any files with consistent naming patterns.

πŸ“₯ Download Standalone Executable (Windows):
Download the latest ready-to-run binary from GitHub Releases (prefix-file-sort-windows.zip). No Python installation required!

✨ Features

  • πŸ” Smart Prefix Detection: Automatically extracts and groups files by their filename prefix (text before the first -)
  • πŸ‘οΈ Real-time Preview: Preview grouping results before executing any file operations
  • ↩️ Safe Undo: Instantly undo the last batch of file moves with one click
  • ⚑ Multi-threaded: Responsive UI that won't freeze during large batch operations
  • 🎯 Flexible Filtering: Filter files by extension (e.g., .mp4, .jpg, .png)
  • πŸ”€ Multiple Sort Modes: Order groups by name, natural order, modification time, or file size
  • πŸ”„ Conflict Handling: Choose how to handle naming conflicts (Skip, Overwrite, Auto-Rename)
  • πŸ“ Drag & Drop: Drag folders directly into the application (when tkinterdnd2 is installed)
  • 🎨 Themes & Languages: Built-in light/dark themes and English / δΈ­ζ–‡ interface
  • πŸ“‹ Activity Log: Track all file operations with detailed logging

πŸ“Έ Screenshots

File Grouper GUI

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • tkinter (usually included with Python)

Installation

  1. Clone the repository:
git clone https://github.com/keyenhuang/prefix-file-sort.git
cd prefix-file-sort
  1. Install dependencies (optional, for drag & drop support):
pip install -r requirements.txt
  1. Run the application:
python main.py

πŸ“– Usage

Basic Usage

  1. Click Browse to select a folder containing your files
  2. Set the Default Suffix for created folders (e.g., series, episode)
  3. Optionally, set a File Filter to only process specific file types
  4. Click Preview Groups to see how files will be organized
  5. Click Execute Move to perform the actual file grouping

Example

Given files in a folder:

01-S01E01.mkv
01-S01E02.mkv
02-S02E01.mkv
02-S02E02.mkv
03-S03E01.mkv

After running with suffix - episodes:

β”œβ”€β”€ 01 - episodes/
β”‚   β”œβ”€β”€ 01-S01E01.mkv
β”‚   └── 01-S01E02.mkv
β”œβ”€β”€ 02 - episodes/
β”‚   β”œβ”€β”€ 02-S02E01.mkv
β”‚   └── 02-S02E02.mkv
└── 03 - episodes/
    └── 03-S03E01.mkv

Numbered Custom Mode

Enable Numbered Custom Mode and provide custom names:

01 - First Season
02 - Second Season
03 - Third Season

The app will use these names instead of the default naming pattern.

Conflict Policies

Policy Behavior
Skip Skip files that would cause conflicts (default)
Overwrite Replace existing files with the same name
Auto-Rename Rename new files to avoid conflicts (e.g., file (1).txt)

Sort Modes

Choose how groups are ordered via the Sort by dropdown (in Robustness Settings):

Mode Behavior
Name (A-Z) Alphabetical by prefix (default)
Natural order Numeric-aware ordering: 2 before 10
Newest first / Oldest first By the newest/oldest file's modification time in each group
Largest first / Smallest first By total file size of each group

πŸ”§ Configuration

File Filter Syntax

Separate multiple extensions with commas:

  • .mp4 - Only process MP4 files
  • .jpg, .png, .gif - Process image files
  • Leave empty - Process all files

Case Sensitivity

Enable Prefix Case Sensitive to treat Episode and episode as different prefixes.

πŸ› οΈ Development

Running from Source

# Install dependencies
pip install -r requirements.txt

# Run the application
python main.py

Testing & Linting

# Run the test suite (headless, no GUI required)
python run_tests.py

# Lint with ruff
pip install ruff
ruff check .

Project Structure

prefix-file-sort/
β”œβ”€β”€ main.py                # GUI application (tkinter) β€” entry point
β”œβ”€β”€ core.py                # Core grouping/move/undo logic (tkinter-free, unit-tested)
β”œβ”€β”€ i18n.py                # Internationalization (English / δΈ­ζ–‡)
β”œβ”€β”€ themes.py              # Light / dark theme manager
β”œβ”€β”€ tests/                 # Unit & integration tests
β”œβ”€β”€ run_tests.py           # Test runner
β”œβ”€β”€ prefix_file_sort.spec  # PyInstaller spec for building a Windows .exe
β”œβ”€β”€ build.bat              # Windows build helper
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ pyproject.toml         # Project metadata & ruff lint config
β”œβ”€β”€ .github/               # CI workflows & issue/PR templates
β”œβ”€β”€ README.md              # This file
β”œβ”€β”€ LICENSE                # MIT License
β”œβ”€β”€ CONTRIBUTING.md        # Contribution guidelines
β”œβ”€β”€ CODE_OF_CONDUCT.md     # Community code of conduct
β”œβ”€β”€ SECURITY.md            # Vulnerability reporting policy
└── CHANGELOG.md           # Version history

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide for details on how to submit pull requests. By participating, you agree to abide by the Code of Conduct.

πŸ”’ Security

Found a vulnerability? Please see SECURITY.md for private reporting instructions β€” do not open a public issue.

πŸ“œ Changelog

See CHANGELOG.md for version history.

πŸ‘€ Author

Keyen Huang

πŸ™ Acknowledgments

  • Built with Python's tkinter library
  • Drag & drop support via tkinterdnd2

About

A smart file grouping tool that organizes files into folders based on their filename prefixes.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages