Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How can I stop LAME adding .wav to output file? Encode by right-click? (Read 10471 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How can I stop LAME adding .wav to output file? Encode by right-click?

I want to encode wav files with the options --vbr-new -V0. With what exact command line do I do this, and also make lame strip the .wav extension (without typing the whole new filename)? Currently, my files get the extension filename.wav.mp3.

The line I've been using is
lame --vbr-new -V0 "Artist - Track Name.wav"

I'd also like to be able to create a right-click context menu for my wav files in Windows 7, so that I could do this with just a couple of clicks. How?

How can I stop LAME adding .wav to output file? Encode by right-click?

Reply #1
If you are using LAME 3.98 or higher, you don't need --vbr-new, as it is the default. See the detailed documentation.

You can pass the desired output filename as a 2nd argument, right after the input filename. See the basic documentation.

Setting up a context menu item is a little trickier. [a href='index.php?showtopic=58166']This discussion[/a] (found via the forum search function) might be of some help.

How can I stop LAME adding .wav to output file? Encode by right-click?

Reply #2
You can pass the desired output filename as a 2nd argument, right after the input filename.

But what would I do if I wanted to encode any wav files in a folder, and remove the .wav extension from all the resulting mp3 files?

Quote
Setting up a context menu item is a little trickier. [a href='index.php?showtopic=58166']This discussion[/a] (found via the forum search function) might be of some help.

Yeah, thanks, I already did have a look at that before posting, but found it not at all easy to understand. For example, I've no idea what %L does (or %d, which I've also seen in some suggested lame command lines). I could just copy the suggested command lines, but would prefer to understand them

How can I stop LAME adding .wav to output file? Encode by right-click?

Reply #3
I want to encode wav files with the options --vbr-new -V0. With what exact command line do I do this, and also make lame strip the .wav extension (without typing the whole new filename)? Currently, my files get the extension filename.wav.mp3.

The line I've been using is
lame --vbr-new -V0 "Artist - Track Name.wav"


What LAME version are you using?

With LAME version 3.99 and newer, the following command line should do the trick, as it replaces common suffixes by .mp3 automatically, if you don't give an output file name:

lame -V0 "Artist - Track Name.wav"

If you want your newly encoded files stored at a special folder for further evaluation, you can add --out-dir "my new mp3s"

LAME change log

PS: Happy New Year!

How can I stop LAME adding .wav to output file? Encode by right-click?

Reply #4
The easiest solution to avoid ".wav.mp3" extensions is to use LAME 3.99 or newer. Regardless, if you are already in the folder of .wav files, you can do this at the command prompt:

Code: [Select]
FOR %F IN (*.wav) DO lame.exe -V0 "%F" "%~nF.mp3"


If you just do for /? then you can read all about what the "FOR" command does and how to use it.

%F is a variable that I chose to name F. It represents one .wav file name at a time. %~nF represents that name without the .wav extension. Double quotes are there in case the file name contains spaces, so LAME doesn't think the spaces distinguish arguments. So the command line says, "in the current folder, for each file name ending with .wav, assign that name to the variable F, then execute lame.exe with three arguments: -V0; the value of F in double quotes; and, also in double quotes, the value of F-without-.wav followed by .mp3"

Were you planning to run this on a folder with hundreds of WAVs in it? I'm not sure, but I think *.wav gets expanded to the same thing as if you typed every .wav file name out by hand, separating them with spaces, and double-quoting any that contain spaces. If this expanded form would exceed 8191 characters, then the command line will be too long and will fail to run. Don't quote me on that, though.


I had some free time today, so I figured out how to add a context menu item for folders. In Regedit, navigate to HKEY_CLASSES_ROOT\Folder\shell. Create a new key (looks like a folder) called "MP3-encode this folder's WAVs" or whatever you want to see in the context menu. Inside that key, create a new key called command. Double-click on its "(Default)" value and paste in this string:

Code: [Select]
cmd.exe /C "cd "%L" && FOR %%F IN (*.wav) DO "E:\apps\lame-3.98.4\lame.exe" -V0 "%%F" "%%~nF.mp3""


You will have to modify the path to lame.exe, of course. It should take effect immediately. If the window just opens and closes, there was an error, or no .wav files to process.

%L, %V, etc. are special variables that only apply to this situation (launching something specified in a 'command' registry key). They're apparently undocumented, but in the Community Additions section of Microsoft's Extending Shortcut Menus how-to, there's a comment by a Microsoft employee that explains what they are. %L is the long file name of the argument, which in this case will be the folder you right-clicked on.

As explained by cmd /?, the /C tells cmd.exe to treat what comes next as a command to run (as if typed at the prompt) and then exit. You can use /K instead if you want the window to remain open. The outer double quotes are stripped; the inner ones are preserved. Just like in batch scripts, variable references must be escaped with an extra "%", so that they're not interpreted by whatever is interpreting the %L.

The current working directory will be the parent folder of the one you clicked on, hence the need to first "cd" to the chosen directory (%L), which is double-quoted in case it contains spaces. "&&" can be thought of as "...and then, if that worked, here's another command to try..."

Insert obligatory "don't mess around too much in Regedit, because you can really screw up Windows" caution here.

 

How can I stop LAME adding .wav to output file? Encode by right-click?

Reply #5
Hey mjb2006, thanks a lot for your effort on this. Yup, I was using 3.98. Fixed that. Also managed to get the encode folder option working. Still working on encoding a single file through context menu, didn't succeed with the tip in the linked thread.