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
- Organizes series into show and season folders:
Anime Name/
Season 01/
Season 02/
Season 00/
- Uses
Season 00for OVAs, specials, pre-broadcast specials, and episode00. - 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
.nfofiles 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, andHitori no Shitavariants collapse together.
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" --applyTo remove empty folders afterward:
python Anime-Sorting-Hat.py "E:\~Anime" --apply --clean-emptyTo only scan the top-level folder:
python Anime-Sorting-Hat.py "E:\~Anime" --no-recursiveNormal 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-sidecarsPreview first. Then apply only if the preview looks right:
python Anime-Sorting-Hat.py "E:\~Anime" --repair-orphan-sidecars --applyanitopy is optional, but it improves anime filename parsing.
pip install -r requirements.txtor:
pip install anitopyCopy the example config:
copy anime_sorting_hat_config.example.json anime_sorting_hat_config.jsonThen 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/
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-groupUse 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.
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.
This project is licensed under the MIT License. See the LICENSE file for details.