A Go tool for automatically renaming music files to match official track listings from MusicBrainz.
This project consists of two complementary tools:
main- Renames audio files in a directory based on MusicBrainz metadatambfind- Searches MusicBrainz to find release IDs for an artist/album
the files in the releases/ directory probably wont work as of right now. oh well!
use go run . from a git clone instead for now
Use mbfind to search for an album and get its MusicBrainz IDs:
go run ./mbfind -artist "Michael Jackson" -album "Dangerous"This outputs a ranked list of matching releases with their:
- Release Group ID (rgid)
- Release ID (mbid)
- Type (Album, Single, etc.)
- First release date
Once you have a release ID, use the main tool to rename your files:
# Using a release ID (most accurate)
go run . -mbid <release-mbid> -dir "/path/to/music/folder"
# Using a release group ID (tool picks best release)
go run . -rgid <release-group-mbid> -dir "/path/to/music/folder"$ go run . -rgid d6b52521-0dfa-390f-970f-790174c22752 -dir "/path/to/Michael Jackson - Dangerous/"
Using release ae5efacd-f75f-432a-9f22-b35d3169d21f: Dangerous
01: "Michael Jackson - Jam.flac" -> "01. Jam.flac"
02: "Michael Jackson - Why You Wanna Trip On Me.flac" -> "02. Why You Wanna Trip on Me.flac"
03: "Michael Jackson - In The Closet.flac" -> "03. In the Closet.flac"
...
14: "Michael Jackson - Dangerous.flac" -> "14. Dangerous.flac"- Fuzzy matching - Intelligently matches existing filenames to track titles
- Safe renaming - Sanitizes filenames to remove problematic characters
- Multi-disc support - Handles albums spanning multiple discs
- Preserves extensions - Keeps original file extensions (.flac, .mp3, etc.)
- Smart release selection - When using rgid, prioritizes official releases from preferred regions
-mbid- MusicBrainz Release MBID (recommended for accuracy)-rgid- MusicBrainz Release Group MBID (script selects best release)-dir- Directory containing audio files (default: current directory)--artist-in-filename- Add artist name prefix to filenames
-artist- Artist name (required)-album- Album title (required)-limit- Number of results to display (default: 10)
- Queries the MusicBrainz API for official track listings
- Scans your directory for audio files
- Matches files to tracks using normalized title comparison
- Renames files to format:
## Track Title.ext
- Go 1.16 or higher
- Internet connection (for MusicBrainz API access)
- The tool skips hidden files (starting with
.) - If file count doesn't match track count, it proceeds with a warning
- Original file extensions are preserved
- Windows-incompatible characters are replaced with safe alternatives
GNU GPLv3
Contact: decbrks@pm.me