I am looking for the action code to remove an existing Tag, within $Tags, within a note that may have several preexisting Tags?
Use Case: I am trying to clean up some notes with old tags, many of these notes have more than 1 note. I am trying to run an agent to find notes that have a particular tag and trying to delete just this one tag. I want to be careful that I keep the other tags in place.
Thanks in advance.
BTW…I found this code for adding a tag to an existing set, but am lost how to remove a tag from an existing set. Action:$Tags=$Tags+“taxi;transportation”
I know (believe / suspect) that there is a way to do this.
I believe that @mwra or some other authoritative figure can tell you the exact way to do so.
Bonus I actually remember / have tested how to do this! Let’s say you want to remove the tag “taxi” from your list of entries, and let’s assume that $Tags is a Set-type attribute.
Create an agent (or any other search vehicle, including an Attribute Browser) that has the query $Tags.contains(“taxi”)
Create an action (or stamp, or whatever) that says $Tags=$Tags-“taxi”
In my test operation, this does the job. More here.
In addition to using a stamp, as suggested, an agent similar to the one described here works when you are sure you want the tag string in question removed everywhere.
as the action for that agent. This sort of action is irreversible, so take care in its use. (The action can also be used in a stamp, if your removal action needs to be more granular as suggested above.
Excellent point especially since I like to monitor the lists of tags I use.
I learned years ago, the hard way, that tags can quickly become less useful if allowed to grow unmonitored and without structure for periods of time. This tip along with using the attribute browser to monitor and remove unwanted tags is very useful to me.
I hadn’t actually applied the .replace operator and so am glad for this illustration of its use.
Also this coding illustration reminds me to clarify something from the example I offered above. Auto-correct in this browser turns “straight” quotes, like the ones you see in @PaulWalters’s original example, into curly quotes “like these” – and even like the ones that have been auto-subbed around “Taxi” into the quote above.
So if you copy-and-pasted the query and action in my post, they wouldn’t work because of the curly-quote issue. The proper form, with straight quotes, is:
$Tags.contains("taxi") and $Tags=$Tags-"taxi"
An outlier point, but if something weren’t working this could be a clue.
DAMHIK.