Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| articles:bulkreplaygain [2026/01/29 20:47] – hjr | articles:bulkreplaygain [2026/01/29 21:14] (current) – hjr | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Adding ReplayGain to FLACs in Bulk ====== | ====== Adding ReplayGain to FLACs in Bulk ====== | ||
| + | ===== 1.0 Introduction ===== | ||
| + | Semplice 2.12 introduced the concept of a " | ||
| + | As such, ReplayGain is rather a nifty idea that (in my experience) works very well for classical music... and, therefore, it's a bit unfortunate that I only just gave Semplice this ability because there' | ||
| + | |||
| + | Accordingly, | ||
| + | |||
| + | I dislike offering bulk update scripts to anyone, really, because doing substantial data changes to a large amount of collected music has the potential to be extremely damaging... and I do not want to damage a music collection that has taken roughly 26 years to amass! On this occasion, however, the addition of new ReplayGain metadata tags isn't doing much harm. It's not likely to obliterate the music in the FLACs, and metadata tags can be removed and re-placed as often as you like without doing damage. So, just this once, a bulk update script seemed plausible. | ||
| + | |||
| + | If you use it, though: **you do so entirely at your own risk**. And for Heaven' | ||
| + | |||
| + | ===== 2.0 The Script | ||
| + | Without elaboration at this stage, here's the script I used against my own music collection: | ||
| < | < | ||
| Line 45: | Line 57: | ||
| ((SKIPCOUNTER++)) | ((SKIPCOUNTER++)) | ||
| fi | fi | ||
| - | # ----- END ORIGINAL CODE BLOCK ----- | ||
| done < " | done < " | ||
| tput civvis | tput civvis | ||
| </ | </ | ||
| + | |||
| + | ===== 3.0 The Script Explained ===== | ||
| + | The script assumes you are running Giocoso and have accordingly created a local, non-Pro, database of what music files exist in which hard disk folders. | ||
| + | |||
| + | It therefore opens by issuing a ' | ||
| + | |||
| + | The results of the query are written out to a local text file, called // | ||
| + | |||
| + | We then read from that text file, one line at a time. For each line, we ' | ||
| + | |||
| + | Should we encounter a folder for which no previous ReplayGain has been computed, we issue the **metaflac --add-replay-gain** command to compute ReplayGain from scratch for all the FLACs in that folder. | ||
| + | |||
| + | As we loop through each folder mentioned in the text file, we keep count of the folders for which we've had to compute ReplayGain and of those we were able to skip because ReplayGain was already computed. As the script runs, you'll see these counters increment steadily. A lot of the other code in the loop is there to provide some textual feedback as to // | ||
| + | |||
| + | ===== 4.0 Running the Script ===== | ||
| + | Save the script in a text file with a .sh extension anywhere on your file system. Let's say you store it in / | ||
| + | |||
| + | chmod +x / | ||
| + | | ||
| + | Once it's executable, you can run it by typing: | ||
| + | |||
| + | cd / | ||
| + | ./ | ||
| + | | ||
| + | Sit back and be patient as it works its way through your music collection. Computing ReplayGain can take a few tens of seconds. Skipping because it's already been computed takes mere fractions of a second. | ||
| + | |||
| + | The thing was not written with beauty in mind: it will flash annoyingly for the duration of its operation! | ||
| + | |||
| + | Note that if you are a 'dip your toes in the water before plunging into the pool' kind of person, you can restrict the script to working on just a tiny part of your collection by way of a test by altering the text of the initial query. | ||
| + | |||
| + | As written, the query simply selects all recordings in the database' | ||
| + | |||
| + | select dirname from recordings where composer like 'Q% order by composer' | ||
| + | | ||
| + | ...means that only composers whose first names begins with a ' | ||
| + | |||
| + | select dirname from recordings order by composer limit 10 | ||
| + | | ||
| + | ...would ensure only the first ten folders of music would get processed. You could check those ten to satisfy yourself that no damage has been done, come back and remove the limit clause and then run the script without any limits or filters. | ||