I'd like to create a button that will paste the folder path from the clipboard and navigate to the specified folder. Currently, I paste the path into the navigation bar and press ENTER, but a button would be more handy. I experimented with the FOLDERCONTENT command, but couldn't figure out how to add this functionality.
Try this in a button:
Go "{clip}" NEWTAB OPENINDEST
Suitable for Ctrl+V hotkey.
/*
===============================================================================
AUTHOR : Ken
Function : Paste, or navigate to path (pastes directly if not a single-path text, suitable for Ctrl+V hotkey)
Created : 2023-08-20
Version : v0.2 (2023-08-31)
===============================================================================
*/
function OnClick(clickData)
{
var cmd = clickData.func.command;
// If clipboard content is not text (files/images), execute paste command and return
if (DOpus.GetClipFormat() != 'text') {
cmd.RunCommand('Clipboard PASTE');
return
}
// Add string trim() method
String.prototype.trim = function(s){s=s||"\\s";return this.replace(new RegExp("^("+s+"){1,}|("+s+"){1,}$","g"),"");}
var clipText = DOpus.GetClip('text').trim(); // Get and trim clipboard text
var lineCount = clipText.split("\r\n").length; // Calculate number of lines
if (lineCount == 1 && DOpus.FSUtil.Exists(clipText)) // If single-line text is a valid path, open it in new tab
cmd.RunCommand('Go "' + clipText + '" NEWTAB') // Modify function as needed
else
cmd.RunCommand('Clipboard PASTE') // Otherwise perform paste
}
Both solutions work perfectly, and can be modified to to open in new tabs (or not), and more. Much appreciated!