Code: Select all
/*
***************************************************************************************************
@Function: Delete the tags (and remove them from tagged items)
@Created : 2022-07-28
@Modified: 2024-06-12
@Version : v0.2
***************************************************************************************************
*/
// Get tag list
#893; // Update tag list
tagexport("<xydata>\Database_backup\XYplorerTag(<date yymmdd-hhmm>).dat", "", 0); // Backup tags database
$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}
// Open dialog
$removeTags = inputselect("Delete the tags (and remove them from tagged items)", "$newtaglist", "," ,3:=2+64+4096, "cancel", 500, 665, "XYplorer", , ":lstmgmt");
// Exit if no tags is selected
if ($removeTags == "") {status "No item was selected from the tag list.", "FF0000", "alert"; end '1==1';
} else { if ($removeTags == "cancel") {end '1==1'} }
// Find items with tags and remove the tags
status "Removing tags: $removeTags";
taglist($removeTags, 2); // Remove from tag list
$taggeditems = quicksearch("tags:" . replace($removeTags, ",", "|"), "%computer%"); // Find the checked tags in %computer%
if (!$taggeditems) {status "Deleted tags: $removeTags"; end 1==1}
showstatus 0; // Turn off the status bar display
foreach($item, $taggeditems, "<crlf>") {
$tags = tagitems("tags", , $item, 1); // Get the tags for each item
$nTags = formatlist($tags, "ft", ",", "!$removeTags"); // Remove tags
if ($nTags != $tags) {tagitems("tags", "$nTags", "$item");} // Add a new list of tags to each list item
}
showstatus; // Open the status bar display
status "Deleted tags: $removeTags"
XYplorer Beta Club