Go to a Parallel Path in Another Partition Without Drilling Down 5 Folders

I'm in this path: K:\Drive T\Software Docs\Utils\DO\Backups

I want to go to this path: M:\Drive T\Software Docs\Utils\DO\Backups

The new path substitutes "M:" for "K:"

Any ideas how I could do this with one click in a button? TIA

You mean like

Go "M:\Drive T\Software Docs\Utils\DO\Backups"

?

Or did you mean a general rule for several other similar cases?

If it’s just a drive letter change, the path field lets you do that just by navigating to the other drive letter and then clicking the ghosted path components that will still be there from the old path (if they also exist in the new location).

"M:" and "K:" are mirrored backup drives. I am looking for a one click option to go from the M:\ path to the identical path in K:\ even when its several subfolders down.

I have kludged the following JScript that "almost works perfectly":

function OnClick(clickData)
{

	DOpus.ClearOutput();

	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection

	if (clickData.func.sourcetab.selected.count == 0)
	{
		DOpus.Output("  (none)");
	}
	else
	{
		var file = clickData.func.sourcetab.selected(0);
		var newpath = String(file).toLowerCase().replace("m:", "K:\\");
		DOpus.Output(newpath);
		cmd.RunCommand('Go PATH="' + newpath + '"');
		cmd.RunCommand('Go UP');
	}
}

It does move from the M drive to the corresponding location
on the K drive. 

Unfortunately, the script only works if the line
"var newpath = String(file).toLowerCase().replace("m:", "K:\\");"

has two backslashes in it. With a single backslash nothing happens.

This would be OK except that the second backslash opens
the selected folder when the button is run. That is why you see
the line "cmd.RunCommand('Go UP');"

Any ideas on a more elegant solution? TIA

The fact that it goes one subfolder too deep has nothing to do with the second backslash (it is required because backslash is an escape character, so if you WANT a backslash in your string, the first one escapes, the second says there is a backslash).
The problem you are facing is that you rely on a selected folder (using sourcetab.selected) whereas what you want is to rely on the current folder the sourcetab is.

I can not use DOpus at the moment, but you should use clickData.func.sourcetab.path instead of selected(0).
I think, something like the line below should also perform the operation directly :
var newpath = clickData.func.sourcetab.path.ReplaceStart("M:", "K:");

And then run the Go PATH with that newpath.

EDIT : Here is what you should do

var srcPath = clickData.func.sourcetab.path;
var ok = srcPath.ReplaceStart("M:", "K:");
DOpus.Output("New Path = " + srcPath);
cmd.RunCommand('Go PATH="' + srcPath + '"');

And if you want to be able to alternate between the two (when on K: you will go to M:, otherwise if on M:, you will end up on K:) :

var srcPath = clickData.func.sourcetab.path;
var root = DOpus.FSUtil.NewPath(srcPath);
root.Root();
if (root == "M:\\") srcPath.ReplaceStart("M:", "K:");
else if (root == "K:\\") srcPath.ReplaceStart("K:", "M:");
DOpus.Output("New Path = " + srcPath);
cmd.RunCommand('Go PATH="' + srcPath + '"');

Note that this is not veryfying the corresponding path exists on the other drive. If it's not you will get an error.

EDIT2/Final thought : wouldn't it be best to have a dual pane lister, with one pane on M: and the other on K: with synchronized navigation ? Whenever you go somewhere on one drive, the other pane follows ...

1 Like

The evaluator lets you set up a button that toggles between the two drives/structures:

Go PATH="{=(Root(source)=="K:\" ? "M:" : "K:") + Mid(source,2)=}"
3 Likes

I still have to dig into that evaluator thing :slight_smile:

Good plan!

Another way is the new Preferences / Frequently Used Paths / Paired Folders feature.

Set up M:\ and K:\ as a pair, with Apply settings to all sub-folders on, and you can then swap between the two in various ways, or open the other half of the pair side-by-side.

With that set up, Go {sourcepath|pair} will switch between the same folder on the two drives.

You can also use it with Nav Lock, dual displays, and sync, depending on the options you choose.

1 Like

Thank you, thank you, thank you. This was what I was looking for. Here is the finished code:

function OnClick(clickData)
{
	DOpus.ClearOutput();

	var cmd = clickData.func.command;

	var srcPath = clickData.func.sourcetab.path;
	var root = DOpus.FSUtil.NewPath(srcPath);
	root.Root();
	if (root == "M:\\") srcPath.ReplaceStart("M:", "K:");
	else if (root == "K:\\") srcPath.ReplaceStart("K:", "M:");
	DOpus.Output("New Path = " + srcPath);
	cmd.RunCommand('Go PATH="' + srcPath + '"');
}

Anyone can swap out other drive pairs.

Thank you for the suggestion. It inspired me to set up a few pairs and become comfortable with it. I may take advantage of it for a future project.

My particular use case may be atypical. M and K drives are dual backups. I update each of them from a third primary drive using automated standalone backup software.