Code: Select all
/*
******************************************************************************
@Author : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-02-27 10:53:08
@Function: Copyto, moveto, backupto to tab folders [operation as root]
@Tags : <empty>
@Version : v0.4
******************************************************************************
*/
$iconFolder = ":showfolders";
$iconCopy = ":copyto";
$iconMove = ":moveto";
$iconBackup = ":backupto";
$selectedItems = <get SelectedItemsPathNames |>;
global $p_tabs = "";
end (!$selectedItems), "No item(s) selected, aborted!";
$dp = get("#800");
$fullMenu = "";
$roots = "copyto|moveto|backupto";
$menu = BuildTabEntries("a", $selectedItems);
if ($dp) { $menu .= <crlf> . BuildTabEntries("i", $selectedItems); }
end (!trim($menu, <crlf>)), "No valid destination tab(s) open, aborted!";
foreach($root, $roots, , "e") {
switch (recase($root)) {
case "copyto" : $fullMenu .= <crlf> . "Copy <selected items> here..." . "<:><:>" . $iconCopy . <crlf> . replace($menu, "__OP__", "copyto"); break;
case "moveto" : $fullMenu .= <crlf> . "Move <selected items> here..." . "<:><:>" . $iconMove . <crlf> . replace($menu, "__OP__", "moveto"); break;
case "backupto": $fullMenu .= <crlf> . "Backup <selected items> here..." . "<:><:>" . $iconBackup . <crlf> . replace($menu, "__OP__", "backupto"); break;
}
}
$selection = popupnested($fullMenu, 6:=<crlf>, 7:="<:>");
if ($selection) { load $selection, , "s"; }
function BuildTabEntries($pane, $selectedItems) {
global $p_tabs;
$indent1 = <space 2>;
$indent2 = <space 4>;
$curPath = <curpath>;
if ($pane LikeI "i") { focus "PI"; }
$tabs = get("tabs", "|");
$cntTabs = gettoken($tabs, "count", "|");
$menu = "";
while ($i++ < $cntTabs) {
$tabFolder = tab("get", "path", $i);
$tabFolderSubs = quicksearch("/d /md=0", $tabFolder);
$tabFolderAndSubs = $tabFolder . <crlf> . $tabFolderSubs;
$tabFolderAndSubs = formatlist($tabFolderAndSubs, "f", <crlf>,"!*Recycle*<crlf>*System Vol*<crlf>*REAgent<crlf>*Recovery");
if ($tabFolder LikeI $curPath) { continue; } // Skip tabs with the same current path
if (strpos($p_tabs, "|$tabFolder|") != -1) { continue; } // Skip duplicate tab paths
$info = tab("get", "name", $i);
$icon = gettoken($info, 2, "|");
if (!$icon) { $icon = ":showfolders"; }
if ($tabFolderSubs) {
$menu .= <crlf> . $indent1 . $tabFolder . "<:><:>" . $icon . "<:>";
} else {
$dataTab = "__OP__" . " " . quote($tabFolder) . ", " . quote($selectedItems) . ", , 2, 2;";
$menu .= <crlf> . $indent1 . $tabFolder . "<:>" . $dataTab . "<:>" . $icon . "<:>";
}
foreach($sub, $tabFolderAndSubs, <crlf>, "e") {
if ($tabFolderSubs) {
$dataSub = "__OP__" . " " . quote($sub) . ", " . quote($selectedItems) . ", , 2, 2;";
$menu .= <crlf> . $indent2 . $sub . "<:>" . $dataSub;
} else {
$menu .= <crlf>;
}
}
$p_tabs .= "|" . $tabFolder;
}
$p_tabs .= "|";
if ($pane LikeI "i") { focus "PI"; }
return trim($menu, <crlf>);
}