I am looking for an XY script that would do the following:
1) Count the number of instances a tag is applied to documents E.g. 15 documents have the tag "London", 10 docs "Rome" etc.
2) Show the result in descending order with the top item on top such as:
London 150
Paris 75
Rome 61
3) Ability to do the counting for ALL tags no matter in which directory they are and
4) Separately or in addion to the above, to restrict the counting to a specific directory.
Any data if such script already exist?
Tag counting
Re: Tag counting
Code: Select all
$path = "";
$items = quicksearch("tags:?*", $path);
$tags = tagitems("tags", , $items, 1);
$tags = regexreplace($tags, "[ ]*?,[ ]+", <crlf>);
$knownTags = "";
while (true) {
if ($tags == "") { break; }
$firstTag = gettoken($tags, 1, <crlf>, "t");
$escTag = regexreplace($firstTag, "([\\.+*|?(){\[^$])", "\$1");
$matchTags = regexmatches($tags, "^" . $escTag . "$", <crlf>);
$cntTags = gettoken($matchTags, "count", <crlf>);
$knownTags .= $cntTags . ":" . $firstTag . <crlf>;
$tags = regexreplace($tags, "^" . $escTag . "(\r?\n|$)");
}
if ($knownTags) {
$knownTags = formatlist($knownTags, "ern", <crlf>);
$knownTags = regexreplace($knownTags, "^(\d+?):(.+?)(?=\r?\n|$)", "$2 $1");
text $knownTags;
}
One of my scripts helped you out? Please donate via Paypal
Re: Tag counting
Ok, I am editing my previous reply as the code works exactly as I laid it out.
The magic word is "focus". It will work ONLY on the focused pane.
Thank you very much.
The magic word is "focus". It will work ONLY on the focused pane.
Thank you very much.