﻿// cmd1
// (c) 2025 Cris

// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/endpoints/redirect.php?page=scripts for development information.

// Called by Directory Opus to initialize the script
function OnInit(initData) {
	initData.name = "cmd1";
	initData.version = "1.0";
	//	initData.url = "https://resource.dopus.com/c/buttons-scripts/16";
	initData.desc = "";
	initData.default_enable = true;
	initData.min_version = "13.0";

}

// Called to add commands to Opus
function OnAddCommands(addCmdData) {
	var cmd = addCmdData.AddCommand();
	cmd.name = "cmd1";
	cmd.method = "Oncmd1";
	cmd.desc = "";
	cmd.label = "cmd1";
	cmd.template = "";
	cmd.hide = false;
	cmd.icon = "script";
}

// Implement the cmd1 command
function Oncmd1(scriptCmdData) {
	var cmd = scriptCmdData.func.command;
	if (!cmd.filecount) {
		DOpus.Dlg.Request('No files!','&OK','',scriptCmdData.func.sourcetab);
		return;
	}
	cmd.RunCommand('cmd2 {filepath}');
	cmd.RunCommand('COPY "{filepath}" COPYTOCOLL=member CREATEFOLDER="coll://cmdtest" WHENEXISTS=skip');
}