A robust Rust utility that automatically updates .cue sheet references when migrating from WAV to lossless formats (FLAC/APE). This tool recursively processes cue files in your music library, intelligently replacing .wav references based on actual audio files present in each directory.
graph TD
A[Start in Current Directory] --> B{Recursive Scan}
B --> C[Find .cue Files]
C --> D{Check Directory Contents}
D -->|FLAC files exist| E[Replace .wav → .flac]
D -->|APE files exist| F[Replace .wav → .ape]
E --> G[Preserve Original Encoding]
F --> G
G --> H[In-Place Update]
-
Intelligent Format Detection:
Automatically selects replacement format based on actual files present:- Prioritizes
.flacif any FLAC files exist in the directory - Falls back to
.apeif APE files exist (and no FLACs) - Skips directories with neither format
- Prioritizes
-
Encoding-Aware Processing:
Handles legacy cue sheets with proper encoding detection:- Tries UTF-8 decoding first
- Falls back to Windows-1252 (common for Windows-created cue sheets)
- Preserves original character encoding in output
-
Recursive Directory Traversal:
Processes all subdirectories depth-first starting from execution point -
Atomic Updates:
Only modifies files when actual changes are needed (no unnecessary writes)
// Core workflow pseudocode
fn process_cue_file(path) {
content = detect_encoding_and_read(path); // UTF-8 → Win1252 fallback
if directory_contains("*.flac") {
content.replace(".wav", ".flac");
} else if directory_contains("*.ape") {
content.replace(".wav", ".ape");
}
if content_changed {
write_with_original_encoding(path, content);
}
}-
Case-Sensitive Replacement
Only replaces lowercase.wav(common in cue sheets) - avoids unintended replacements in metadata -
Directory Context Awareness
Checks actual files present before making replacements - prevents broken references -
Encoding Preservation
Maintains original character encoding through Windows-1252 fallback handling -
Minimal-Impact Updates
Skips unchanged files and avoids backup clutter (intentional design choice)
| Consideration | Impact | Mitigation |
|---|---|---|
| No backups created | Original files overwritten | Use with version control or manual backups |
Only replaces .wav |
Won't fix .WAV or mixed case |
Pre-process files with case normalization |
| String-based replacement | May replace in comments | Verify critical cue sheets manually |
| FLAC priority | Prefers FLAC even if APE is primary | Organize libraries by format type |
You can donwload binary from repo, build locally, or build inside docker (linux, windows). Docker-compose build up - generates windows executable by default (target\x86_64-pc-windows-gnu\release\cue_editor.exe).
- Test first on a small directory subset
- Version control: Run in a Git-tracked directory (
git add . && git commit -m "pre-update") - Verify critical albums after processing:
grep -r "\.wav" . --include=*.cue # Check for missed replacements
- Combine with verification tools like
cuetoolsfor integrity checks
💡 Pro Tip: For large libraries, pair with
rcloneorresticto create point-in-time snapshots before processing.
encoding_rscrate for robust Windows-1252 handling- Standard Rust filesystem and encoding libraries
- No external system dependencies required