Code: Select all
/*
***************************************************************************************************
@Function: Find by Tags & Labels List
@Created : 2022-04-11
@Modified: 2024-06-12
@Version : v5.6
***************************************************************************************************
*/
// Get tag list
$taglist = formatlist(taglist(), "t", ","); // Get tag list
$selTags = replace(tagitems("tags", , , 1), "|", ","); // Gets the tags of the selected item
$vSelTags = formatlist($selTags, "sdt", ","); // Remove duplicate tags
// If there are no items with empty tags
if ($vSelTags && trim($vSelTags, ",") == $vSelTags) {
$newtaglist = formatlist($taglist, "f", ",", "!$vSelTags"); // Remove the tags to be checked from the tag list
$newtaglist = "+" . replace($vSelTags, ",", ",+") . ",$newtaglist"; // Check the tags of the selected items (add +) and combine them into a new tag list
} else {$newtaglist = $taglist}
$lbl="<Search Here>, Red, Orange, Yellow, Green, Blue, Purple, Grey";
// Combination
$tg = $lbl . ",$newtaglist";
// Open the Find window
$text=inputselect("Find by Tags & Labels List", "$tg", "," ,3:=2+64+4096, "cancel", 500, 665, "XYplorer", , ":qns");
if ($text == "") {status "No item was selected from the tag list.", "FF0000", "alert"; end '1==1';
} elseif ($text == "cancel") {end '1==1'}
$lbl2 = "";
$tags = "";
$find = "%computer%?";
foreach($text1, $text, ",", "e") {
if (formatlist($lbl, "f", ",", $text1) && $text1 != "<Search Here>") { // If it is a label, stack with |
$lbl2 .= "$text1" . " | ";
} elseif ($text1 != "<Search Here>") { // If not label or <Search Here>, stack with |
$tags .= '"' . $text1 . '"' . " | ";
} elseif ($text1 == "<Search Here>") { // If it is <Search Here>, $find equal to "<curpath>?"
$find = "<curpath>?";
}
}
if ($lbl2 != "" && $tags != "") { // If $lbl and $tags not empty, stack to find
$data = "$find" . "lbl:" . "$lbl2" . "tags:" . "$tags";
} elseif ($lbl2 == "") { // else, if $lbl2 is empty, stack to find by tags
$data = "$find" . "tags:" . "$tags";
} elseif ($tags == "") { // else, If $tags is empty, stack to find by label
$data = "$find" . "lbl:" . "$lbl2";
}
$data = substr($data, 0, -3); // Trim" | "
if ($data == "<curpath>?ta") {$data = $data . "gs:"}
end ("$data"=="%computer%?tags:<Search Here>"), "Nothing selected, Abort!";
tab("new", "$data");