Merge two tags (i.e. TAG2 into TAG1)

I have tags with TAG1 and TAG2. Now I decide to merge TAG2 into TAG1 as duplicated tag or similar meaning.

How should I update all links/references from TAG2 to TAG1, then delete TAG2?

You can use a $button containing a $list that finds tags with “TAG2” and invokes $action-listops on each, like this:

<$let tag1="TAG1" tag2="TAG2">
<$button> Change <<tag2>> to <<tag1>>
<$list filter="[tag<tag2>]"><$action-listops $tags="[<tag1>] -[<tag2>]"/></$list>
</$button>

!!Tiddlers with <<tag1>>:
<$list filter="[tag<tag1>]"><<currentTiddler>>: {{!!tags}}<br></$list>

!!Tiddlers with <<tag2>>:
<$list filter="[tag<tag2>]"><<currentTiddler>>: {{!!tags}}<br></$list>

Thanks @EricShulman, your method will update tags. How about all other links/references (e.g. all tiddlers found by relink:backreferences)?

Do you have actual tiddlers for TAG2 and TAG1?

If you do NOT already have such tiddlers, there’s an easy solution: you can make use of the relink function by creating a tiddler named TAG2, and saving that tiddler. Then open it again, change its title to TAG1, and confirm that you DO want relink to redirect all backlinks.

If there’s already a tiddler named TAG1 (and its contents matter to you), then it’s more complicated. (And, if there are backlinks, it’s probably because real content is held by those tiddlers.)

Still, you might try renaming the existing TAG1 without letting relink do its work. Then, rename TAG2 as TAG1 (with the relink function). Then you can figure out how to merge whatever content you have in the old TAG1 tiddler.

Whenever you merge actual tiddlers, there will be some risks that shouldn’t be approached in a formulaic way. There might be additional information in one or both of those tiddlers (in the list fields, in the created/modified fields, in the color/icon fields associated with how they display as tags, or in the actual text fields, etc.) that you might need to compare and evaluate, choosing in each case which values belong in the new “merged” tiddler.

2 Likes