~/Music — sorting rules (AGENTS.md — for Claude, Codex, Kimi, any agent)#
House style for this library. Follow it exactly; do not invent a new scheme. Last applied: 2026-09-07.
Layout#
~/Music/
Alternative/ Electronic/ Metal/ Punk/ genre → Artist/[YYYY]_Album/NN._Track.flac
Playlists/ one FLAT folder per playlist
Traditional/ one FLAT folder, all mp3
unsorted/ inbox — must end up EMPTY
.sort_manifest_<date>.tsv append "<new path>\t<old path>" for every move
Everything in the library uses underscores instead of spaces in file and
folder names. / is not legal in a filename — substitute the lookalike the
target folder already uses: ⁄ (U+2044) under Playlists/, ⧸ (U+29F8)
under Traditional/. No other character is rewritten: : ? * [ ] & + = @ #
are all kept verbatim. Strip any leading dot from a generated filename — an
artist like .diedlonely would otherwise produce a hidden file that MPD skips.
Keep the real name in the tags.
unsorted/ is an inbox, not storage. When a job is done there must be no files
and no empty directories left in it.
1. Playlists#
Trigger: a folder that came down as a playlist download (it has a
<playlist name>.txt download report next to the music).
Never rename the playlist. Whatever the user called it — however long, however rude, emoji and all — is the name. Do not tidy it, do not shorten it, do not ask about it.
Destination#
~/Music/Playlists/<Playlist_Name_Underscored>/ — flat. Every track sits
directly in that one folder. Delete the per-artist / per-album subfolders the
downloader made. Keep the .txt report, renamed to underscores, in the folder.
Tags#
For every track, read the original ARTIST / TITLE / ALBUM first, then:
| Tag | Value |
|---|---|
ARTIST, ALBUMARTIST, ALBUM |
the playlist name (spaces, real casing, emoji intact) |
TITLE |
<orig artist> - <orig title> - <orig album> |
ORIGINALARTIST |
original ARTIST |
ORIGINALTITLE |
original TITLE |
ORIGINALALBUM |
original ALBUM |
TRACKNUMBER |
position in the playlist (see order, below) |
TRACKTOTAL, TOTALTRACKS |
number of tracks in the playlist |
DISCNUMBER, DISCTOTAL, TOTALDISCS |
1 |
The TITLE always carries all three parts, even when title and album are
identical (Chromatics - Kill For Love - Kill For Love). This is the one
place the artist and album belong in a title — the point of a playlist is that
the player shows it as one album, so the per-track credit has nowhere else to
live.
Multi-artist tags arrive semicolon-separated (Air;Gordon Tracks). Join them
with , for ORIGINALARTIST and for the TITLE string.
Everything else the downloader wrote — COMMENT COMPOSER COPYRIGHT DATE
GENRE ISRC LABEL LYRICS PUBLISHER UPC — is preserved untouched.
Use metaflac --remove-tag= for the thirteen tags above and then --set-tag=
them back in the table's order; that keeps byte-for-byte consistency with the
playlists already sorted.
Track order#
Comes from the .txt download report, not from the source album track
numbers. Lines read [DONE] <title> - <artist, artist> (older reports say
[SUCCESS]). Match each line to a file on f"{TITLE} - {ARTIST joined by ', '}"
— it is an exact 1:1 match — and number them 1..N in report order.
[FAILED] lines have no file and get no number: N is the number of files.
Filenames#
<orig artist>_-_<orig title>_-_<orig album>.flac, dropping the album
segment when it is identical to the title (Kaleida_-_Think.flac, not
Kaleida_-_Think_-_Think.flac). Note this is not the same rule as the TITLE
tag, which always keeps all three. Drop the downloader's [ISRC] and
(Explicit) markers. On a name collision, suffix _(2), _(3).
2. Albums (Alternative/, Electronic/, Metal/, Punk/)#
Trigger: anything that is not a playlist.
<Genre>/<Artist_Name>/[YYYY]_<Album_Name>/NN._<Track_Title>.flac
Genre is chosen per artist, not per track. NN is the zero-padded track number.
Drop the [ISRC] from the filename; keep a trailing (Explicit) marker.
Tags stay as the downloader wrote them. In particular:
TITLEis the bare song title — no artist, no album. The folder tree already says who made it and what it is on; repeating that in the title is noise. If a title arrives asArtist - Song - Album, strip it back toSong.
ARTIST is the performing artist(s), ALBUMARTIST the album's artist, ALBUM
the real album name. Never write the playlist-style triple title here.
3. Traditional (Traditional/)#
One flat folder of mp3s. Filename and TITLE are the same string:
<Culture>_-_<Song>_-_<Descriptor>.mp3 → TITLE=<Culture> - <Song> - <Descriptor>
The culture prefix is the nationality/tradition (Irish, Occitan, Byzantine,
Crusader, Iberian, …) and is repeated in GENRE. Drop the YouTube
[videoid] from the name. Remove the culture word from the descriptor once
the prefix carries it — Levanta Pascual - Spanish Reconquista Song becomes
Spanish_-_Levanta_Pascual_-_Reconquista_Song.mp3.
| Tag | Value |
|---|---|
title |
<Culture> - <Song> - <Descriptor> |
artist |
the performer if there is a named one, otherwise Traditional |
album |
Traditional Music |
album_artist |
Traditional |
genre |
the culture prefix |
Retag with ffmpeg -c copy -map_metadata -1 and the five -metadata flags, so
no download junk survives.
4. Duplicates#
Traditional downloads in particular arrive in overlapping topic folders
(saints/ and crusaders/ both held Le Roi Louis). Filenames lie — compare
the audio.
ffmpeg -v error -i FILE -map 0:a -c copy -f md5 -
Index Traditional/ by that hash first, then check each incoming file. Retagging
changes the container, so byte size and whole-file md5 give false negatives; the
audio-stream hash does not. If the hashes differ but the duration matches to a
tenth of a second it is the same recording at a different bitrate — still a
duplicate; keep the higher bitrate, which is normally the copy already sorted.
Do not delete duplicates. Move them to
unsorted/_duplicates_already_sorted_<date>/, say so in the summary, and let the
user delete the folder.
Working notes#
- Always dry-run the rename/retag plan and check for collisions before applying.
- Append every move to
~/Music/.sort_manifest_<date>.tsvas<new path>\t<old path>. - Filenames on disk may be Unicode NFD while a string typed into a script is
NFC. Normalise both sides (
unicodedata.normalize("NFC", …)) before matching. - Report what was moved, what was quarantined, and anything left inconsistent.
Known outstanding#
Playlists/This_Is_Always_Mirin/(32 tracks) is filed underPlaylists/but was never retagged — it still carries per-trackARTIST/ALBUM/TITLEinstead of the playlist convention above. Its.txtreport was not kept, so the playlist order cannot be reconstructed; ask the user before assigning track numbers to it.Playlists/Deutschland_Tekk/(71 tracks) andPlaylists/I_want_to_put_a_bullet_in_my_head_ahh_music/(123 tracks) use a deliberate hybrid at the user's request (2026-09-07):ARTISTandALBUMARTISTare the real artist,TITLEthe bare song title, and onlyALBUMis the playlist name — so Discord RPC shows the actual artist/song with the playlist as the album.TRACKNUMBER(playlist order) and theORIGINAL*tags were kept. Do not "fix" them back to the full playlist convention.