Variables and DOS windows

Admin note:

This discussion was original in the Buttons & Toolbars thread "Encode/Transcode selected WAV/MP3 files to MP3 using LAME". I have split it into a separate thread, below.

Once the discussion results in a finished button please post it into the original thread, but let's keep ongoing discussion in here so people can easily find buttons, rather than talk about buttons, in the Buttons & Toolbars area. :slight_smile:


Good idea! Now I can copy optimized mp3-files to my player (used an external program before).

I add some variables to choose the quality. How can I use the choosen bitrate for ALL files without DO prompting for each file?

<?xml version="1.0"?> <button display="both" label_pos="right"> <label>Encode MP3</label> <icon1>12</icon1> <function type="batch"> <instruction>___PATH___\lame.exe {dlgchoose|Choose quality to encode:|VBR ~240 kbps (0 - Extreme)=-V 0 --vbr-new+VBR ~190 kbps (2 - Standard)=-V 2 --vbr-new+VBR ~165 kbps (4 - Medium)=-V 4 --vbr-new+CBR 320 kbps=-b 320+CBR 192 kbps=-b 192+CBR 160 kbps=-b 160+CBR 128 kbps=-b 128} {filepath$} {destpath$}{file$|ext=mp3}</instruction> </function> </button>

Does this do the trick?

<?xml version="1.0"?> <button display="both" label_pos="right"> <label>Encode MP3</label> <icon1>12</icon1> <function type="batch"> <instruction>dopusrt /cmd ___PATH___\lame.exe {dlgchoose|Choose quality to encode:|VBR ~240 kbps (0 - Extreme)=-V 0 --vbr-new+VBR ~190 kbps (2 - Standard)=-V 2 --vbr-new+VBR ~165 kbps (4 - Medium)=-V 4 --vbr-new+CBR 320 kbps=-b 320+CBR 192 kbps=-b 192+CBR 160 kbps=-b 160+CBR 128 kbps=-b 128} {filepath$} {destpath$}{file$|ext=mp3}</instruction> </function> </button>

Steje, Why use "dopusrt /cmd" there?

You should use variables if you want to collect information from drop-downs etc. and re-use it for every file.

Hello Nudel,

could you please tell me which variable I can use so that the drop-down information will be used for every file? All I tried was without success.

And is there an option that allows another entry than the first one in the drop-down to be selected by default (nothing found in the manual/reference list)?


Here is the example that's in the manual and release notes:

@set dir = {dlgstring|Enter new folder name to copy files to} createfolder ".\{$dir}" copy to ".\{$dir}"

Yes, but I'm not that good in programming :cry:. I'll try it...

I found nothing about setting the default option in "dlgchoose" (in this button I want the 3rd option "-V 4" selected by default, without changing the order).

Edit: I didn't realize to solve this problem with a variable, I just tried it with "allfile" etc.!

Okay, finally the modified button for encoding x files @ x quality. I deleted the pause because otherwise too much ms-dos-windows may stay open.

<?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>___ENTER_PATH___\lame.exe &quot;{$var}&quot; {filepath$} {destpath$}{file$|ext=mp3}</instruction> </function> </button>

I haven't tried the button but I'd expect only one MS-DOS window to open for the entire operation, even if more than one file got processed.

I believe you'd want to use @sync at the beginning of the command line. This will make the files be transcoded one at a time, instead of many windows opening.

I've been tinkering with an audio toolbar. I'll try to post it pretty soon. It can also make ogg vorbis and mp4 files, along with some lossless formats.

If I knew of a program which would copy tags from any tag style to another, that would be great. As it is, tags are lost except in flac > ogg.



@sync isn't needed in this case. It's only needed between internal and external commands in some cases.

So how can I change the button to have all files encoded within one MS-DOS-window?

You don't have to change anything. It works that way by default!

I just tried the exact button shown above, with LAME.exe 3.96.1, and it encodes each file in turn using the same output window:

Hm, my DO opens a window for each file :confused:

Did you use "my" button?

I did, yes.

Either it's not set to MS-DOS Batch type (but it is according to the button definition) or your version of LAME.exe is opening a new window for each instance (which would be odd) or we're not running the same version of Opus ( here).

My button is set to MS-Batch and DO (german version from H&P).

Lame is v3.97 (latest), but I can't imagine that this is the reason (nevertheless I'll try your version when I'm home and report then).

waouuuuu i love it !!!

but i have two questions.
i want to overwrite exiting file automatically. how can do that ?

Since it's a DOS command the easiest thing is to add

del {destpath$}{file$|ext=mp3}

before the call to lame.exe

I don't know why all encoded files were open in a separate window yesterday. I changed nothing and now only one window appears :question: :confused: :exclamation:


about dopusrt /cmd...
Yes variables are the way to go... it's just that "usually" I find that dopusrt /cmd still "fixes" the multiple prompt thing depending on the command it's with... seems to work when used with actual opus functions as opposed to external programs... it's come up in a few other topics where the same situation is fixed with internal Copy commands or similar.

I'm using v3.97 here as well and only get one window for all files being processed. Are "YOU" sure you're using the exact same button as the last one you posted, and hadn't modified it any further?

@nudel again:
Not sure this is what he wants to do... seems like he might want to 'replace' the "source" files with whatever he's re-encoding to... and I don't see how you're going to do that unless you still re-encode to a 'destination' dir first, then 'move' the files to the "source" folder... or, unless you use some renaming acrobatics...