IPB

Welcome Guest ( Log In | Register )

How can I stop LAME adding .wav to output file? Encode by right-click?, [TOS #6: was "Lame command line problems"]
nannaloori
post Jan 1 2013, 21:28
Post #1





Group: Members
Posts: 4
Joined: 1-January 13
Member No.: 105527



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?

This post has been edited by nannaloori: Jan 1 2013, 21:47
Go to the top of the page
+Quote Post
 
Start new topic
Replies (1 - 5)
mjb2006
post Jan 2 2013, 02:23
Post #2





Group: Members
Posts: 786
Joined: 12-May 06
From: Colorado, USA
Member No.: 30694



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. This discussion (found via the forum search function) might be of some help.

This post has been edited by mjb2006: Jan 2 2013, 02:31
Go to the top of the page
+Quote Post
nannaloori
post Jan 2 2013, 10:33
Post #3





Group: Members
Posts: 4
Joined: 1-January 13
Member No.: 105527



QUOTE (mjb2006 @ Jan 2 2013, 03:23) *
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. This discussion (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
Go to the top of the page
+Quote Post
robert
post Jan 2 2013, 11:17
Post #4


LAME developer


Group: Developer
Posts: 788
Joined: 22-September 01
Member No.: 5



QUOTE (nannaloori @ Jan 1 2013, 21:28) *
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!
Go to the top of the page
+Quote Post
mjb2006
post Jan 2 2013, 21:12
Post #5





Group: Members
Posts: 786
Joined: 12-May 06
From: Colorado, USA
Member No.: 30694



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
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
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.

This post has been edited by mjb2006: Jan 2 2013, 21:21
Go to the top of the page
+Quote Post
nannaloori
post Jan 3 2013, 10:35
Post #6





Group: Members
Posts: 4
Joined: 1-January 13
Member No.: 105527



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.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 29th August 2014 - 03:56