Tags quandary - how do I merge tag that have different case

142 views
Skip to first unread message

Farayi Chambati

unread,
Jul 18, 2016, 4:52:16 AM7/18/16
to TiddlyWiki

I have a tag like "Movie" and "movie". How do I rename one or how I merge these? My queries are now very complicated because of this. OR what do you recommend?


RichardWilliamSmith

unread,
Jul 18, 2016, 7:37:47 AM7/18/16
to TiddlyWiki
Hi Farayi,

I made this for you, it's a "tag re-tagger" - it can swap one tag for another (existing) tag over all tiddlers. let me know if it works. Please make a copy of your wiki before using it.

Copy the following into a tiddler - it doesn't matter what it's called;

!!!This removes one tag and adds another
Be careful. There is no undo.
<table>
<tr>
<td>
remove
</td>
<td>
<$select tiddler=<<currentTiddler>> field="tagtoremove" default='notset'>
<$list filter='[all[tiddlers]tags[]]'>
<option value=<<currentTiddler>> field="tagtoremove"><$view field='title'/></option>
</$list>
</$select>
</td>
<td>
and add
</td>
<td>
<$select tiddler=<<currentTiddler>> field="tagtoadd" default='notset'>
<$list filter='[all[tiddlers]tags[]]'>
<option value=<<currentTiddler>> field="tagtoadd"><$view field='title'/></option>
</$list>
</$select>
</td>
<td>
<$set name="newTag" value={{!!tagtoadd}}>
<$set name="oldTag" value={{!!tagtoremove}}>
<$button>
<$list filter="[all[shadows+tiddlers]tag{!!tagtoremove}]">
<$fieldmangler>
<$action-sendmessage $message="tm-add-tag" $param=<<newTag>>/>
<$action-sendmessage $message="tm-remove-tag" $param=<<oldTag>>/>
</$fieldmangler>
</$list>
Click me!
</$button>
</$set>
</$set>
</td>
</tr>
<tr>
<td>
</td>
<td>
<$list filter="[all[shadows+tiddlers]tag{!!tagtoremove}]">
<li><$link>{{!!title}}</$link></li>
</$list>
</td>
<td>
</td>
<td>
<$list filter="[all[shadows+tiddlers]tag{!!tagtoadd}]">
<li><$link>{{!!title}}</$link></li>
</$list>
</td>
<td>
</td>
</tr>
</table>

If you want to put this tool in the control panel, give it the tag $:/tags/ControlPanel and if you want it to disappear from the regular search results, give it a title that starts with $:/

Regards,
Richard

Farayi Chambati

unread,
Jul 18, 2016, 8:27:01 AM7/18/16
to TiddlyWiki
Much appreciated RichardWilliamSmith,

I will have a play in a sandbox and I will add it into production.

reakt...@gmail.com

unread,
Jul 18, 2016, 11:25:13 AM7/18/16
to tiddl...@googlegroups.com
You may also want to check out the Search and Replace Tag wizard - http://tobibeer.github.io/tb5/#Search%20And%20Replace%20Tag

Farayi Chambati

unread,
Jul 19, 2016, 5:51:30 AM7/19/16
to TiddlyWiki
Thanks RichardWilliamSmith again. The utility worked a treat. I have applied in the production file.

Best regards,

Farayi Chambati

unread,
Jul 19, 2016, 5:53:00 AM7/19/16
to TiddlyWiki
Thanks Reakt..

Matabele

unread,
Jul 19, 2016, 1:44:13 PM7/19/16
to TiddlyWiki
Hi Farayi

The ActionListops widget is designed for this kind of operation and simplifies code considerably -- to search and replace a tag use with the replace[] filter operator like so:

<$button>
<$list filter="[tag[oldtag]]">
<$action-listops $tags="newtag +[replace[oldtag]]"/>
</$list>
Do This
</$button>

-- the $tags filter will operate on the 'tags' field of the current tiddler
-- the 'newtag' entry appends the tag to replace with to the end of the list
-- the replace[oldtag] filter operator searches for 'oldtag' and replaces it with the last item in the list ('newtag' in this case)
-- the list filter is used to select the list of tiddlers to operate on (this may be any listing -- in this case the list of tiddlers with 'oldtag')

Hope this helps

regards

Farayi Chambati

unread,
Jul 20, 2016, 4:54:43 AM7/20/16
to TiddlyWiki
Thanks Matabele.
Reply all
Reply to author
Forward
0 new messages