MS-DOS Batch Command

Hi all, I am having a bit of a problem making this custom command to work properly.

@runbatch C:\Apps\x264_encoder\x264.exe --crf 18 -o Temp.mkv {file$} C:\Apps\MKVtoolnix\mkvmerge -o {file$|noext}.new.mkv -D {file$} Temp.mkv Delete NORECYCLE FORCE QUIET Temp.mkv
It's a simple script and it works only if I have a single file selected. If I select more than one it doesn't process the commands properly. It runs the x264 encoder line the same number of times as I have files selected before going to the next line. So if I have 3 files selected, it runs the encoder for those 3 files before it goes to the next line. That completely ruins the encoding because it overwrites the temp file so you get the same video for each conversion. I have tried putting @sync in front of each of the lines but it doesn't help. A simple fix would be to change the temp file to be based off of the original file name like {file$|noext}.tmp.mkv but that is not really a good solution because you will need more HD space for the conversion.

So what I need is to be able to run that script for multiple selected files one at a time in that exact order before going to the next file.

If you have File1 and File2, and this command:

line1 {file} line2 {file}

Opus always runs this:

line1 File1 line1 File2 line2 File1 line2 File2

Do you want this instead?

line1 File1 line2 File1 line1 File2 line2 File2

That's possible, but you have to move the main two lines into a separate User Command or into a standard .bat file, and have the main command call that for each file.

(You don't need @runbatch at all, by the way.)

If that's what you want, let me know which method you'd prefer and I can give an example, if you need one.

Yes the latter one is what I need.

line1 File1
line2 File1
line1 File2
line2 File2

I guess I would take the current user command I have in the opening post then call it from another user command and that will fix the order of execution. An example would be nice, I do not know how to pass parameters to a user command.

OK I got it figured out. Thanks for the help :slight_smile:

In case anyone else needs to know how to do it:
first define your initial batch of commands that will process each file (I'll call this "ProcessFile") :

//ProcessFile fname
//Processes a single file represented by fname variable
C:\Apps\x264_encoder\x264.exe --crf 18 -o Temp.mkv &fname&.mkv
C:\Apps\MKVtoolnix\mkvmerge -o &fname&.new.mkv -D &fname&.mkv Temp.mkv
Delete NORECYCLE FORCE QUIET Temp.mkv

here fname is my filename variable I am passing to it with another program called "Convert" :

//Convert
//takes one or more selected files and passes each one one at a time to be processed by function ProcessFile
ProcessFile {file$|noext}

To be able to pass in the filename to ProcessFile you need to put "fname" in the Template box for that function and it all works nicely. Just remember in your custom menu you only need to have the second program (in this example "Convert") listed. So now I can select a bunch of files select convert and it properly does each file. :slight_smile:

I ran into another issue that I am not sure why it is happening. Given this code:

IF "{file$|ext2}"=="001" (
ECHO "File OK"
Delete RECYCLE {file$|noext|escregexp|escwild}.#[0-9]
) ELSE (
echo "nothing to do."
)
:END
PAUSE

No matter what I do it always calls the delete command, in addition it doesn't print the text in the cmd window or pause. The cmd window flashes on screen for a half a second and closes immediately then the dialog box for deleting the files comes up. If I remove the Delete line above the program works as expected and prints the appropriate text based on the file extension to the opened cmd window and pauses.

I think it has to do with how dopus runs the command so I tried to put a @sync: in front of Delete and the program seems to follow the flow but I get an error that 'Delete' is an unknown internal or external program so nothing happens. The normal dos "del" command works in this case but it deletes permanently instead of to the recycle bin so it's not really a solution.

You can't mix DOS batch flow control and Opus commands as any Opus command causes the batch to be split in two.

You can either run the Opus commands via dopusrt.exe /acmd or use the equivalent DOS command instead, e.g. del.

OK I thought that dopus split internal commands only when it was called. I didn't realize it was split and called as long as a command was listed in the batch file.