Skip to content

About

Organize anime files effortlessly with this Python script tailored for [GroupName] Anime Name - S##E##.mkv naming conventions. Automatically categorize episodes by anime name and season, creating structured directories for easy access and management. Ideal for anime enthusiasts seeking a streamlined way to manage their collection.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Anime Sorting Hat

Anime Sorting Hat is a safer Python organizer for anime libraries. It scans anime video files and organizes them into show/season folders, with support for messy real-world release names.

It was built for filenames like:

[SubsPlease] Kekkon Yubiwa Monogatari - 01v2 (720p) [50A1AF4D].mkv
[GuodongSubs] Hitori no Shita - S03-01 [40921809].mkv
[SubsPlease] Dorohedoro - OVA (720p) [75F66B45].mkv
Demon.Slayer.Kimetsu.No.Yaiba.Infinity.Castle.2025.1080p.WEB-DL.mkv

What it does

  • Organizes series into show and season folders:
Anime Name/
  Season 01/
  Season 02/
  Season 00/
  • Uses Season 00 for OVAs, specials, pre-broadcast specials, and episode 00.
  • Sends detected one-off movies to Movies/.
  • Sends unclassified files to Misc/.
  • Supports recursive cleanup of an already-sorted library.
  • Moves matching sidecar files with videos, such as .nfo, .srt, .ass, and .ssa.
  • Does not let orphan .nfo files create folders during normal runs.
  • Supports custom aliases so related titles can be merged under one canonical name.
  • Includes built-in Hitori No Shita aliases so The Outcast, Rust Iron Returns, and Hitori no Shita variants collapse together.

Safety first

The script is dry-run by default. It previews what it would move without changing files.

python Anime-Sorting-Hat.py "E:\~Anime"

To actually move files:

python Anime-Sorting-Hat.py "E:\~Anime" --apply

To remove empty folders afterward:

python Anime-Sorting-Hat.py "E:\~Anime" --apply --clean-empty

To only scan the top-level folder:

python Anime-Sorting-Hat.py "E:\~Anime" --no-recursive

Orphan sidecar files

Normal runs only move .nfo, .srt, .ass, and other sidecars when there is a matching video file with the same base name.

That means an orphan file like this will not create a show folder by itself:

Some Random Metadata.nfo

If you intentionally want to repair orphan sidecars, use:

python Anime-Sorting-Hat.py "E:\~Anime" --repair-orphan-sidecars

Preview first. Then apply only if the preview looks right:

python Anime-Sorting-Hat.py "E:\~Anime" --repair-orphan-sidecars --apply

Install

anitopy is optional, but it improves anime filename parsing.

pip install -r requirements.txt

or:

pip install anitopy

Configuration

Copy the example config:

copy anime_sorting_hat_config.example.json anime_sorting_hat_config.json

Then run with:

python Anime-Sorting-Hat.py "E:\~Anime"

When anime_sorting_hat_config.json sits next to Anime-Sorting-Hat.py, it is loaded automatically. You can still pass --config path\to\config.json to use a different file.

Example alias use:

{
  "aliases": {
    "hitori no shita": "Hitori No Shita",
    "hitori no shita - the outcast": "Hitori No Shita",
    "the outcast": "Hitori No Shita",
    "rust iron returns": "Hitori No Shita"
  },
  "dash_normalize_whitelist": [
    "Hitori No Shita"
  ],
  "skip_folders": [
    "Movies",
    "OVAs",
    "Misc",
    ".venv",
    "Anime-Sorting-Hat"
  ]
}

This helps collapse title variants like:

Hitori no Shita - The Outcast
Hitori no Shita - Rust Iron Returns
Hitori no Shita S6

into:

Hitori No Shita/

Filename cleanup

By default, leading release group tags are removed from destination filenames:

[SubsPlease] Show - 01.mkv

becomes:

Show - 01.mkv

To keep release group tags:

python Anime-Sorting-Hat.py "E:\~Anime" --apply --keep-release-group

Helper: generate alias suggestions

Use the alias helper to scan a library and suggest likely title aliases:

python tools/generate_alias_suggestions.py "E:\~Anime"

It writes alias_suggestions.txt by default. Review the suggestions manually before adding them to your config.

Notes

Anime filenames are messy. No parser is perfect, especially when official titles change across seasons. For best results, use the JSON config aliases for known problem series.

License

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

About

Organize anime files effortlessly with this Python script tailored for [GroupName] Anime Name - S##E##.mkv naming conventions. Automatically categorize episodes by anime name and season, creating structured directories for easy access and management. Ideal for anime enthusiasts seeking a streamlined way to manage their collection.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages