Findexisting anyside

Go somefolder NEWTAB=findexisting

recycles a tab in the source, if found. If not, a new tab is created in the source.
If the tab exists in the target but not the source, the same tab is created in the source.

Would there be a raw command that allows you to recycle a tab if it is found either in the source or in the target?
Looked but couldn't find this. :slight_smile:

The EXISTINGLISTER argument could be used, except it not only considers the destination side but tabs in other windows as well.

A script command could be written to do your exact requirements.

Thank you Leo, EXISTINGLISTER sounds perfect.

Unless I'm misunderstanding, in Dual mode it's not working as advertised, i.e.

For instance


does not shift the focus to the Recycle Bin when it's on the target side.



does not shift the focus when the Recycle Bin is on the target side.

It does activate the tab, but you're right in that it doesn't shift the focus if the Lister itself is already active.

In that case, would you consider adding a findexistingdual that behaves like findexisting, except in a dual lister it will recycle an existing tab if it is found on either side, giving it focus?

I'm sure you have a huge list already, just a suggestion — seems like it could be useful in a number of situations (for people like me who are using commands but haven't yet explored the scripting interface).

Here you go :slight_smile:

// PlayfulGo
// This is a script for Directory Opus.
// See for development information.
// Called by Directory Opus to initialize the script
function OnInit(initData)
{ = "PlayfulGo";
	initData.desc = "";
	initData.copyright = "";
	initData.version = "1.0";
	initData.default_enable = false;

	var cmd = initData.AddCommand(); = "PlayfulGo";
	cmd.method = "OnPlayfulGo";
	cmd.desc = "Equivalent of Go NEWTAB=findexistingdual";
	cmd.label = "PlayfulGo";
	cmd.template = "PATH";

// Implement the PlayfulGo command
function OnPlayfulGo(scriptCmdData)
	if (scriptCmdData.func.sourcetab.lister.dual == 0)
		scriptCmdData.func.command.RunCommand('Go "' + scriptCmdData.func.args.path + '" NEWTAB=findexisting');
	if (!DoPlayfulGo(scriptCmdData, scriptCmdData.func.sourcetab.lister.tabs))
		scriptCmdData.func.command.RunCommand('Go "' + scriptCmdData.func.args.path + '" NEWTAB');

function DoPlayfulGo(scriptCmdData, tabs)
	var FSUtil = DOpus.FSUtil();
	var e = new Enumerator(tabs);
	var index = new Array(0, 0);
	while (!e.atEnd())
		if (FSUtil.ComparePath(e.item().path, scriptCmdData.func.args.path))
			if (scriptCmdData.func.sourcetab.right != e.item().right)
				scriptCmdData.func.command.AddLine('Set FOCUS=toggle');
			scriptCmdData.func.command.AddLine('Go TABSELECT ' + index[e.item().right ? 1 : 0]);
			return true;
		++index[e.item().right ? 1 : 0];
	return false;

Jon, that's really terrific, thank you so much.

It seems like it could be useful to more people so I've advertised it as RecycleGo on this thread and mentioned it here on the DearOpus scripts page.

What about calling it "GoRecycle" instead of "RecycleGo"?
That way all "Go" commands line up in the list of commands and its much easier to find "Go"-related functionality.

Another thing: The script behaves different for existing tabs/paths in left or right of a dual lister.
If I'm on the left side (has focus) and both sides have a tab with a path with potential to be recycled, it will bring the tab from the left side to the front, focus stays left and will not move over to the right (expected bahviour).

If I'm on the right side (has focus) and both sides have a tab with a path with potential to be recycled, it will choose the tab on the left side and give that focus. The behaviour of the command is not "mirrored", so to say and comes unexpected for this case.

Will somebody fix that? o)

Be my guest :slight_smile:

@tbone To my ears GoRecycle might sound ambiguous, as in "Go to the Recycle Bin", but what do you think?
Let me know your thoughts, I don't have your "view from the mountaintop" of the Opus command landscape and fully trust your good judgment. If you think it's a better name I'll edit the thread on the scripting board. Also please feel free to take ownership of the script if you feel it deserves further versions — I've only glanced at it as I haven't studied the scripting interface. The non-mirrored aspect doesn't bother me (I might even like it, being more of a source-on-the-left kind of guy) but I can see how someone else could like to control that with a parameter.

Maybe "GoExisting" is a better name, avoiding the unwanted association with the Recycle Bin.

That sounds great, I'm sure tbone will like that too. Updated the thread on the scripting board, I don't think anyone will mind at this early stage.

"GoExisting" is marvelous! o)

I really had that recycle bin association at first btw., so Leo and Playful, I fully agree.. o)