External command multiple files with same args

When I create a command using {dlgstring} to get a parameter and {filepath} to specify the file(s), the string requester dialog is displayed for each selected file. If I use {allfilepath}, the dialog is only displayed once, but the target application has to be able to handle being called with multiple files specified as args.

Is there a way to run an external command once for each selected file (as with the {filepath} code) but display requester dialogs only once, then use the same args for each file (as with the {allfilepath} code)?



You could try using Nudel's Setclip Command Line Program.
Something similar to this might be a start:

sync:C:\YourPath\SetClip.exe "{dlgstring}" YourCommand {clip} {filepath}
It's difficult to specify exact syntax without knowing exactly what you are attempting though.

Any thoughts Nudel ?


Ken filed a feature request to have simple variables in Opus commands which, if implemented in the next version, should make this problem a thing of the past. Fingers crossed there.

For now you can use something like Zippo suggested, if you don't mind your clipboard being overwritten, or you could move your commands into a batch file or VBScript or similar which you pass all the arguments to in one go, including the {dlgstring} and any selected items that you need.

Thanks for the replies. I justed switched from Magellan Explorer to DOpus as I was tired of ME's bugs and lack of any new releases. I find DOpus to be much better in every area. ME does, however, allow you to specify that an external command will be called once for each file using args gathered once through dialogs. I'm glad consideration is being given to a method which will make this easier in the future.

FWIW - I was exploring methods to implement search/replace across multiple files. Some apps allow command line parms to specify the search and replace strings, but only operate on a single file. These apps wouldn't work easily with the SetClip method because two string args are needed. I settled on using perl which will deal with multiple files:
perl -p -i.bak -e "s/{dlgstring|Enter Search Text|}/{dlgstring|Enter Replace Text|}/g;" {allfilepath$}


There is another option here.
The delete probably isn't safe, but it's only there to make certain the file no longer exists.
However, I know another member of this forum is good at doing this part correctly.

MS-DOS Batch Function

del Yourpath\files.txt echo {filepath$} >> Yourpath\files.txt Yourbatchfile "{dlgstring}" "{dlgstring}"

The batch file then accesses the textfile for the filenames and executes an external command line program for each.
I have done this kind of thing in the past, but don't use it anymore.
I eventually found other solutions to those problems.

It does seem though that jfath has found a good solution though.
I thought I'd mention it though.


MS-DOS Batch Function

echo {filepath$} > Yourpath\files.txt Yourbatchfile "{dlgstring}" "{dlgstring}"

If you mod the code with > instead of >> the file isemptied before something is written.

Then it won't work when more than one file is selected.

Unless you're still using Opus 8, though, this is probably all irrelevant. Opus 9 was released since this thread was started and adds features which let you do all of this in a much better way:

[ul][li]@Set and {$var} let you create variables which are defined once and then used in multiple places in the same command.
[li]{file|file}, {file|filem}, etc. let you automatically put the list of selected files into a temporary file and pass the filename of the tempfile to something else.[/li][/ul]

Is it possible then to select several files, say, file1.ext, file2.ext, and file3.ext, and copy to the clipboard the filename, no ext, surrounded by a command like "\input{...}", like (including the open/close braces):


i was playing with the @set and $, but couldnt get rid of the braces without the filenames being "unexpanded"

Opus has a Clipboard SET command but I'm not sure it will work in this particular case, since you need it to add something for each filename.

However, you can do it using my small SetClip utility and a button like this:

@runmode hide @nofilenamequoting @set leftBrace { @set rightBrace } SetClip.exe -e SetClip.exe -a "\input{$leftBrace}{file|noext}{$rightBrace}"
This example is complicated a bit because you want to include literal { and } characters in the results, which meant I had to create the leftBrace and rightBrace variables in order to insert them without confusing Opus, but it seems to work fine.

The SetClip.exe -e line clears the clipboard and then the SetClip.exe -a line is repeated for each selected file and appends it to the clipboard.

You can pass a literal { by escaping it with another {, eg:

@runmode hide @nofilenamequoting SetClip.exe -e SetClip.exe -a "\input{{{file|noext}}"

Note that you don't need to escape the }.

Okay, thanks! Works great.