Bragi is a small Rust command-line tool for organizing and playing a local music
library. It scans the current directory for MP3 and FLAC files, reads track
metadata, and moves songs into an All_Songs/<Artist>/<Album>/<Title>.<ext>
library layout.
It can also open tracks through the system audio player and create portable M3U playlists from the sorted library.
- Sort MP3 and FLAC files by artist, album, and title metadata.
- Keep FLAC files when both FLAC and MP3 versions of a track are present.
- Sanitize generated folder and file names for filesystem compatibility.
- Reuse existing artist and album folder casing when possible.
- Browse and play sorted tracks with an interactive fuzzy picker.
- Create M3U playlists interactively, randomly, from filters, or by importing an
existing
.m3uor.m3u8playlist.
- Rust toolchain with Cargo.
- A terminal that can run interactive
skimpickers forplayand interactive playlist creation. - A system application associated with audio files for
bragi play.
Clone the repository and build the binary:
cargo build --releaseThe optimized binary will be written to target/release/bragi.
For local development, run commands through Cargo:
cargo run -- --helpRun Bragi from the root of the music directory you want to manage. The sorter
creates and maintains an All_Songs directory in the current working directory.
cargo run -- sortRunning without a subcommand also sorts music:
cargo runThe sorter skips files without usable metadata and prints a summary of moved files, skipped conflicts, and read errors.
cargo run -- playThis reads tracks from All_Songs, opens an interactive fuzzy picker, and opens
the selected file with the system default audio application.
Playlists are written to Playlists/<name>.m3u with paths relative to the
playlist file.
Create a playlist from an interactive multi-select picker:
cargo run -- playlist --name FavoritesCreate a random playlist:
cargo run -- playlist --name Shuffle --random 25Filter playlist candidates by artist, album, or genre:
cargo run -- playlist --name Jazz --genre jazz
cargo run -- playlist --name Beatles --artist "The Beatles"
cargo run -- playlist --name Roadtrip --artist "Nina Simone" --album "Pastel Blues"Import an existing M3U or M3U8 playlist and match entries against the sorted library:
cargo run -- playlist --name Imported --import ~/Music/old-playlist.m3u--import cannot be combined with --random, --artist, --album, or
--genre.
Bragi organizes supported audio files into:
All_Songs/
Artist/
Album/
Title.flac
Other Title.mp3
Playlists/
Favorites.m3u
Only .mp3 and .flac files are currently supported.
Bragi is intended for personal music libraries built from music bought or otherwise obtained through official sources, such as purchased downloads, ripped personal CDs, or other authorized collections.
Users are responsible for complying with copyright law and the terms of the stores, services, and licenses that apply to their music. This project does not endorse piracy or unauthorized distribution.
Useful commands:
cargo check
cargo test
cargo fmt --check
cargo clippy --all-targets --all-featuresRun cargo fmt before committing code changes.
Bragi operates on files under the current working directory. Before running it against an important library for the first time, use a backup or a copy of a small subset to confirm the resulting layout matches your expectations.