Howto: define which lister should get a command

I'd like to have a hotkey that selects a set of files from the lister on the right, and then copies them to the lister on the left. To ensure that this will always run as expected, even if I invoke it when the left lister is active, I've added a "set source=right" at the beginning of the script. The script looks like this:

set source=right select "testfilter" filter copy

The problem is that the "set source=right" command does not seem to work as I expected. It momentarily changes focus to the right lister, but then the next two command (the "select" and the "copy") are run on the left lister.

Is there a command I can use to shift the focus to the right lister for the entire script?

Yeah - it's just the addition of the select command AFTER the 'set source' command that seems to cause the source to revert back to the left. Weird... and seems like a bug.

THAT SAID - this isn't the first time where what someone is trying to do makes me thinhk we could use a FROMLEFT/FROMRIGHT and/or a FROMSRC/FROMDST arguments for the select command. Just to add a level of specificity to doing things between displays.

You'd probably be better off using a single-line Copy command, since you can pass the from/to folders you want, plus a filter, to the Copy command. Then you don't have to play around with the selection or which side has focus.

Thanks, Leo. That seems like a more straightforward solution, too.

By the way: in the meantime, I managed to get the script working by using the following workaround: after changing the focus, I ran all subsequent commands through dopusrt, rather than directly. That is, I rewrote the script above as follows:

set source=right "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd select "testfilter" filter "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd copy

These extra calls to dopusrt.exe do the trick, ensuring that the lister with the current focus is the one on which the command is executed.

For future reference, though, I'd like to please clarify what to expect from the script processor in these types of situation. From this limited example, it seems to me that the script processor takes note of the lister that has focus at the beginning of the script, and it executes all subsequent commands on that lister, even if the lister focus changes in the middle. According to this theory, Dopusrt.exe is an effective workaround because it effectively starts each line as its own independent script, thus ensuring that the script processor checks to see what the current lister is at the beginning of each command.

Is this a correct description of what is happening? Is this the designed behavior?

You can use "dopusrt" without the full path within buttons. Opus will work out the full path and insert it for you.

That is more or less the behaviour. There are some special cases where changing the source/dest mid-command is enabled.

In general, it's not something you should worry about as it's not something you should do in the first place. :slight_smile: There are usually better ways to do things which do not involve messing with what's selected/active in the UI (or the clipboard, another thing people often do which is only really needed in exceptional cases).

OK, I've rewritten the script as a single line command, as per Leo's recommendation. For anyone who's following this thread who might be interested, here is the working result:

copy {r}\*.* filter "testfilter" to {l}

This single line copies all files that pass the filter from the right lister to the left lister, regardless of which lister is currently in focus.

By the way, if you're doing a Copy TO {leftpath} or similar, watch out for queued copies. They may copy their files to the current leftpath, not the leftpath at the time they were queued. (It's on our todo list.)