Improve the Encode MP3 button?

In the Buttons forum there is a topic about encoding WAV to MP3: [Encode/Transcode selected WAV/MP3 files to MP3 using LAME)

<?xml version="1.0"?> <button display="both" label_pos="right" separate="yes"> <label>Encode MP3</label> <icon1>12</icon1> <function type="batch"> <instruction>@set var = {dlgchoose|Select encoding quality:|VBR ~165 kbps (4 - medium)=-V 4 --vbr-new+VBR ~190 kbps (2 - standard)=-V 2 --vbr-new+VBR ~240 kbps (0 - extreme) =-V 0 --vbr-new+CBR 128 kbps=-b 128+CBR 160 kbps=-b 160+CBR 192 kbps=-b 192+CBR 320 kbps=-b 320}</instruction> <instruction>C:\SpezProgramme\LAME\lame.exe &quot;{$var}&quot; {filepath$} {destpath$}{file$|ext=mp3}</instruction> <instruction>Pause</instruction> </function> </button>
How can I achieve these improvements to this button:

  1. Save the encoded/decoded/transcoded file automatically in the source directory (no asking for destination directory),

  2. automatically ENCODE selected WAV files and DECODE selected MP3 files,

  3. get this button in the context menu of WAV and MP3 files.

1: change {destpath$} to {sourcepath}
2: this would be dependant on the external program (lame in this case) being able to do this, and you would need to work out the appropriate command line arguments for this from the lame documentation
3: In Settings / Filetypes, locate the entries for WAV and MP3, and add the command to the context menus as appropriate

You could do the second thing using some relatively simple VBScript glue.

There's an example here which makes a different command run depending on whether a file or directory is selected. If you know a bit of VBScript then it should be easy to adapt to do different things with different file extensions. (If you don't then shout and I'll have a look when I get time.)

Some command-line music converters decide whether to encode or decode automatically depending on the type of file passed to them but I can't remember if LAME does (or can).