Want Button/Context Menu Item to Normalize MP3s with MP3Gain

I would like to right click on a folder and have DOpus pass all MP3s in the folder to MP3Gain for normalization. I'd love a one click option--open the files, normailze, and then save them. At this point I'd like to use the standard 'apply Track Gain' option, but it would be nice to know how to add MP3Gain parameters to change the options.

These posts have reference for the MP3Gain options to pass to Command Line:


Thanks for any help. I'm just getting started creating and editing buttons and scripts, so I'm learning from lots of you folks out here.


I'm not familiar with MP3Gain's command line details but if you can work out the command line you want to use (either per file or per folder) then we can tell you how to make Opus run it.

A good thing to do is try the command line from a Command Prompt, without Opus being involved at all, to make sure you have what you want. Trying to make an Opus button at the same time can complicate things, as you aren't always sure if the command line itself is wrong or the button that is generating it.

Thanks for the reply. I'm not that experienced with command line either, so I guess I have some learning/figuring out to do...

Try this. Set button function to MS-DOS and adjust the path to your mp3gain.exe.

Works with selected files:

C:\mp3gain.exe -r {allfilepath$} 

Works with selected folders:

C:\mp3gain.exe -r {filepath$}\*.mp3  

A quick shot without much testing. Feel free to complain if it needs tweaking.


The file one works (though I got a dialog that said "Windows cannot find pause" or something like that. I removed "pause" from the script and it was fine. My understanding is that just lets you read the output of the commands and isn't needed for the script.

The folder one is not working. I get:

Can't open C:\Users\Brad\Documents\FaLaLaLaLa\FaLaLaLaLa Music_2018\Cap\Pelham, Jimmy - Santa, Watch Your Klaws*.mp3 for reading

So it seems like the *.mp3 isn't getting the files.

Thanks for the help so far!

Issue 1 arose because you didn't set the button function to MS-DOS.

For issue 2 try quotes:

mp3gain.exe -r "{filepath$}\*.mp3"

With issue 1, you are correct. Fixed.

For issue 2, still no go. Same error.

Also, it seems the {filepath$} variable already contains the final slash. When I use what you gave me I get:

Can't open C:\Users\Brad\Documents\FaLaLaLaLa\FaLaLaLaLa Music\_2018\Test\Christmas Mix 2018\\*.mp3 for reading

When I remove the slash after {filepath$} I get:

Can't open C:\Users\Brad\Documents\FaLaLaLaLa\FaLaLaLaLa Music\_2018\Test\Christmas Mix 2018\*.mp3 for reading

Again, thanks for your help.

(Edited to fix slashes. --Leo)

Interesting. The forum is stripping one of the slashes. The first example above should have two slashes before *.mp3

It should work with and without the slash and the quotes. Where do see the message? Did you set button function to MS-DOS (it's needed not just for the pause to work)? If that is all ok, test with simpler filenames and shorter paths. Which version do you use? Mine is 1.2.5.

Have a look at the Editing & Formatting Tips, very helpful guide :slight_smile:

1 Like

I had written out a step-by-step response to your (helpful) questions, but before completing my response I did a bunch of testing/troubleshooting and solved the issue.

The problem seemed to be with spaces in the folder names/path. So in your code I changed {filepath$} to {filepathshort$} and it worked!

Here's what I used:

C:\Program Files (x86)\MP3Gain\mp3gain.exe -r {filepathshort$}*.mp3

I found also that this didn't seem to work with quotes around the filepath part of of the script.

There's one more modification I'd like to make. Right now it doesn't work on MP3s in any subfolders. I'd like it to do that if possible. If not, no big deal.

Thanks, once again, for your patience with a relative newbie. It is GREATLY appreciated!


Sometimes adding things like the *.mp3 to the end can confuse the automatic quoting.

This should work without having to resort to short paths (which aren't always enabled on all drives or Windows installs):

"C:\Program Files (x86)\MP3Gain\mp3gain.exe" -r "{filepath$}*.mp3"

Leo, I tried your script and got the same error in the Command Prompt window, "Can't open...".

Are you running things on paths with extremely long names? That's another situation where short names may make things work, at least with some tools.

MP3Gain probably doesn't have a recurse function, so the easiest way is Opus' Flatview for folders or the Find function and the button for files.

If I open MP3Gain through the Windows GUI and drag a folder (full of other folders) onto it. It will recursively add the subfolders.

Might work:

"C:\Program Files (x86)\MP3Gain\mp3gain.exe" -r {filepath$|noterm}