Change tag name

130 views
Skip to first unread message

Gideon Dresdner

unread,
Jun 4, 2020, 6:50:03 AM6/4/20
to TiddlyWiki
Hello,

I have a seemingly basic question. How can I change the name of a tag?

Suppose I have a tag called "My Special Tag" and I want to change it to "The Best Tag in the Universe." How can I change it so that all the wikis that are tagged with the first tag ("My Special Tag") become tagged with the second tag. The first tag should also be removed.

Many thanks from a tiddlywiki newbie,
Gideon.

TonyM

unread,
Jun 4, 2020, 7:00:54 AM6/4/20
to TiddlyWiki
Gideon,

Using the tag pill on a tiddler,

Or <<tag  "My Special Tag" >> click the first line the tags name, this goes to the tags tiddler (if it was one) or allow you to edit it so it becomes a tiddler as well as a tag.

Save it

Rename the tags actual tiddler and it will update wherever the tag is used. Check  Update test to Testit in the tags and list fields of other tiddlers to be sure.

Regards
Tony

Mohammad

unread,
Jun 4, 2020, 2:03:34 PM6/4/20
to TiddlyWiki
While Tony gave a very good answer to your question you may also the Tiddler-Commander!


--Mohammad

Gideon Dresdner

unread,
Jun 6, 2020, 1:24:46 PM6/6/20
to tiddl...@googlegroups.com
I wound up using TonyM's solution,

Using the tag pill on a tiddler,

Or <<tag  "My Special Tag" >> click the first line the tags name, this goes to the tags tiddler (if it was one) or allow you to edit it so it becomes a tiddler as well as a tag.

Save it

Rename the tags actual tiddler and it will update wherever the tag is used. Check  Update test to Testit in the tags and list fields of other tiddlers to be sure.

I tried something similar before I posted to the group, but somehow it wasn't intuitive to me that I had to save and then update. Anyway, works like a charm.

Thanks a lot!
Gideon.

springer

unread,
Jun 6, 2020, 6:38:47 PM6/6/20
to TiddlyWiki
For future readers of this thread, there's also Alberto Molina's special solution, here:


which doesn't require creating a tiddler for the tag, and also is much lighter-weight than the very powerful TW-Commander.

-Springer

Eric Shulman

unread,
Jun 7, 2020, 12:02:18 AM6/7/20
to TiddlyWiki
On Saturday, June 6, 2020 at 3:38:47 PM UTC-7, springer wrote:
For future readers of this thread, there's also Alberto Molina's special solution, here:
which doesn't require creating a tiddler for the tag, and also is much lighter-weight than the very powerful TW-Commander.

Here's another solution:
<$select tiddler="$:/temp/changetag/old" default="">
   <option value="">select an existing tag...</option>
   <$list filter="[tags[]sort[]]"><option><<currentTiddler>></option></$list>
</$select>
<$edit-text tag="input" tiddler="$:/temp/changetag/new" default="" placeholder="enter a new tag..." />
<$button> change
   <$list filter="[tag{$:/temp/changetag/old}]">
      <$action-listops $tiddler=<<currentTiddler>> $field="tags" $subfilter="-[{$:/temp/changetag/old}] [{$:/temp/changetag/new}]" />
   </$list>
   <$action-deletetiddler $tiddler="$:/temp/changetag/old" />
</$button>
<$button> reset
   <$action-deletetiddler $filter="[prefix[$:/temp/changetag]]" />
</$button><br>
Change these tiddlers:<br>
<$list filter="[tag{$:/temp/changetag/old}]"> <li><$link/></li> </$list>

Notes:
* The $select gives you a droplist of all current tags in the document (plus a prompt text at the top of the droplist)
* The selected tag is stored in $:/temp/changetag/old
* The $edit-text lets you input a new tag name into $:/temp/changetag/new
* The change $button loops over all tiddler matching the old tag and uses $action-listops to remove the old tag and add the new tag
* The change $button also resets the selection in the list of tags (since the selected tag no longer exists in the document)
* The reset $button clears both temp inputs
* The $list that appear below the form controls shows you which tiddlers will be re-tagged

enjoy,
-e


TonyM

unread,
Jun 7, 2020, 12:51:47 AM6/7/20
to TiddlyWiki
Eric,

This is nice an elegant. I tested it on Tiddlywiki.com and realised perhaps an option to also rename the tag tiddler as well, eg HelloThere

Thus the tiddlers so tagged rejoin there parent? 

Otherwise my solution of renaming an existing tag tiddler is safer?

Regards
Tony

HansWobbe

unread,
Jun 7, 2020, 6:54:08 AM6/7/20
to tiddl...@googlegroups.com
Eric:

Very nice!  This now enhances/replaces my use of Alberto's code that I've been using happily since 2014.  I really like the way you've structured these new utilities.  They are very easy to understand and use as a base for other personalized utility functions.

Eric Shulman

unread,
Jun 7, 2020, 8:34:43 AM6/7/20
to TiddlyWiki
On Saturday, June 6, 2020 at 9:02:18 PM UTC-7, Eric Shulman wrote: 

I've made a small change to my previous "change tag" code:

when you press the "change" button, instead of simply clearing the current select list value,
it now sets the select list value to the new tag value and clears the "new" tag input.  This makes
it easy to change the same tagged tiddlers again (e.g., in case you made a typo or changed your mind)

The code differences are shown below using red text:
 
<$select tiddler="$:/temp/changetag/old" default="">
   <option value="">select an existing tag...</option>
   <$list filter="[tags[]sort[]]"><option><<currentTiddler>></option></$list>
</$select>
<$edit-text tag="input" tiddler="$:/temp/changetag/new" default="" placeholder="enter a new tag..." />
<$button> change
   <$list filter="[tag{$:/temp/changetag/old}]">
      <$action-listops $tiddler=<<currentTiddler>> $field="tags" $subfilter="-[{$:/temp/changetag/old}] [{$:/temp/changetag/new}]" />
   </$list>
   <$action-setfield $tiddler="$:/temp/changetag/old" text={{$:/temp/changetag/new}} />
   <$action-deletetiddler $tiddler="$:/temp/changetag/new" />
</$button>
<$button> reset
   <$action-deletetiddler $filter="[prefix[$:/temp/changetag]]" />
</$button><br>
Change these tiddlers:<br>
<$list filter="[tag{$:/temp/changetag/old}]"> <li><$link/></li> </$list>
 
enjoy,
-e
Reply all
Reply to author
Forward
0 new messages