Page 2 of 2

Re: Find all tags

Posted: 17 Jul 2015 15:19
by highend
All files that appear in the window are either tagged, labelled or have a comment.

Code: Select all

    $lb = "<crlf>";
    $items = "";
    foreach($item, "<get SelectedItemsPathNames <crlf>>", $lb) {
        if (exists($item) == 1) { $items = $items . $item . report("?{Tags}?{Label}?{Comment}", $item) . $lb; }
        else { $items = $items . folderreport("files:{fullname}?{Tags}?{Label}?{Comment}", "r", $item, "r", , $lb) . $lb; }
    }

    $tagged = regexmatches($items, ".*?\?\w+\?\?$", $lb);
    $labelled = regexmatches($items, ".*?\?\?\w+\?$", $lb);
    $commented = regexmatches($items, ".*?\?\?\?\w+$", $lb);
    $items = regexmatches(formatlist($tagged . $lb . $labelled . $lb . $commented, "dents", $lb), "^.*?(?=\?)", $lb);

    if ($items) {
        if (confirm("Tags/Labels/Comments present. View?")) { text $items; }
    } else { status "Selected items neither have a tag, label or comment", , "stop"; }

Re: Find all tags

Posted: 04 Feb 2022 03:40
by Norn
Find by Tags & Labels List

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");