GoRootArchive is an extended version of the built-in command Go ROOT
. When you run it while navigating a file that Opus recognizes as an archive, it will jump back to the root of the archive, which is the file itself. In all other cases, it will navigate to the root of the current folder, just like the standard command.
How to set up and use
Save CommandGoRootArchive.js.txt to ↓
%appdata%\GPSoftware\Directory Opus\Script AddIns
Add the new command to a button, hotkey, context menu, etc. like any built-in command, or run it from the FAYT Command field.
Things you might enjoy reading
How to use buttons and scripts from this forum
The script's inner workings
JScript
function OnInit(initData) {
initData.name = 'GoRootArchive';
initData.version = '2024-06-20';
initData.url = 'https://resource.dopus.com/t/gorootarchive-jump-back-to-the-root-of-an-archive/51408';
initData.desc = 'Jump back to the root of an archive';
initData.default_enable = true;
initData.min_version = '12.0';
}
function OnAddCommands(addCmdData) {
var cmd = addCmdData.AddCommand();
cmd.name = 'GoRootArchive';
cmd.method = 'OnGoRootArchive';
cmd.desc = 'Jump back to the root of an archive';
cmd.label = '';
cmd.template = '';
cmd.hide = false;
cmd.icon = 'script';
}
function OnGoRootArchive(scriptCmdData) {
var cmd = scriptCmdData.func.command;
var tab = scriptCmdData.func.sourcetab;
var fsu = DOpus.FSUtil();
cmd.deselect = false;
var insideArchive = false;
do {
if (!String(tab.path)) continue;
if (fsu.GetType(tab.path, 'a') != 'file') continue;
insideArchive = true;
break;
} while (tab.path.Parent());
if (insideArchive) {
cmd.RunCommand('Go PATH="' + tab.path + '" OPENCONTAINER');
cmd.RunCommand('Go PATH="' + tab.path + '" OPENCONTAINER');
} else {
cmd.RunCommand('Go ROOT');
}
}