Normalizing volume of your music library

I have a fairly large music library of music that I have been carting around and adding to over the past 25 years. I have found that in the long run I prefer having my own music collection vs. paying for a music service. One issue I have had is that when I play it in a random playlist of songs I find the volume fluctuates, sometimes substantially, between songs. I decided to try to remedy this. What I found was that there was a lot more to this than I thought. My first attempt was to use a process I found in my Plex server. I found that this did not work all that well. So I went back to the drawing board. I did a lot of web research and found a program called mp3gain. It does a better job of normalizing the music to a set level by analyzing each song. My next issue was how do I get it and how do I use it. I found that the terminal version is included in the Fedora repo so I could install it using DNF. Here is the command I used.
sudo dnf install mp3gain
I copied a file into a test directory and tested it on a single mp3 file that is always one I have to turn the volume down on and it worked well. I did not notice any quality change but I could tell that the volume was a little lower. My next test was on a folder for an album and I got the same results. The command for both instances is:
mp3gain . -r -c *.mp3
The -r option sets all music to the default level (89)
The -c option tells mp3 gain to commit the change.
*.mp3 runs it on all files that match the .mp3 ending in the file name.
Now I am ready to go out to /Music and run it on my library. I found that I was getting errors trying to run it unless I was directly in the directory that contains the mp3 files.
My next step was to create a command that would sequentially feed the mp3gain the file I wanted normalized. I used find with -exec. It is running now. It takes me about 1 to 3 seconds per file. in my case I estimated it will take me just shy of 4 hours but it actaully seems like it is going a lot faster than that. I am at 2 hours and it is about 70% done. This is on a sample of almost 6K files.
All my music is in my Music directory with a sub directory for artist and then a sub directory for the album. I navigated to my ~/Music directory and ran this command:
find . *mp3 -exec mp3gain -r -c {} ;
if you don’t know the find command do yourself a huge favor and go do a tutorial on it. it is really critical to effectively using linux. You can get away without using it but it will help you be way more effective if you have a good grasp on the command. Here is a breakdown of what I have above.
find . *.mp3 finds each file ending in .mp3.
-exec executes a command. in my case mp3gain -r -c
{} and ; work in tandom.
{} is a place holder that tells mp3gain -r -c what to exectute against.
; tells find to break up the list sequentially as opposed to running it as a huge batch. Actually the \ is just an escape charactor you need. ; is what is really telling find how to break up it’s results.

I have seen a few errors come through as this is executing. They are mostly on very large files. But for the most part it is working like a charm.

As mp3gain can be given more the 1 file at a time its often better to do

find . *mp3 -exec mp3gain -r -c {} +

This will call mp3gain with as many files as the os allows because of the +.
The saving is the startup time of the mp3gain program.

Oh…so it will still hit each mp3? I thought the + would group all the results in one batch and then run it once on that batch. My thinking was that would fail or at best result in just one mp3 getting updated.

I assume that since you show calling mp3gain called with *.mp3 it processes all files passed to it. In which case the + will work.