Get Path of selected folder onclick()

Hi,

I can't figure out using JScript how to grab the selected path of the current folder? I can get the parent, but I want what's selected.

The goal of the script is to run a CMD with the current selected folder to tell dropbox to unsync.

function OnClick(clickData)
{
	// --------------------------------------------------------
	DOpus.ClearOutput();
	// --------------------------------------------------------
	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection
	// --------------------------------------------------------
	run()	
	function run() {
    	var oShell = new ActiveXObject("Shell.Application");
		var selectedPath = clickData.func.sourcetab.selected_dirs; // https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Tab.htm
		var path = DOpus.FSUtil.Resolve(selectedPath);
		DOpus.Output(path);
		var cmd = "Set-Content -Path '" + path + "' -Stream com.dropbox.ignored -Value 1";
		DOpus.Output(cmd);
    	//oShell.ShellExecute(comspec, cmd, "", "", "1"); 
 	}
}

The default script shows how to loop through files. Create a new button, set it to script mode, and you'll see it.

But you don't need scripting for this. You can do it from a normal button. Just run the command you want with {filepath$} where you want the filename to be, and Opus will automatically run it once for each selected item. You can use @dirsonly to restrict it to only running on directories and not files.

1 Like

Thanks @Leo , didn't realize there was as default script. I was just duplicating from another button so didn't see the default. Thanks!

1 Like