Renaming tags (search and replace)

3,104 views
Skip to first unread message

Albertononi

unread,
Jan 14, 2014, 11:50:41 AM1/14/14
to tiddl...@googlegroups.com
I have just created a tiddler that allows me to search and replace the name of my tags. It works with two steps:
  1. It shows the tiddlers with the old "to-be-replaced" tags. With a checkbox, I can give them the new tags.
  2. It shows the tiddlers with the old AND new tags. With a checkbox, I can remove the old tags.

I guess it could be done with a single step, but I'm not a programmer so I don't know how to do that. (I've tried and failed!)

The title of the tiddler is "RenameTags".
The old name is written in a field called: "search".
The new name is written in a field called: "replaceby".

This is the content of the tiddler:

|!Search tag: | {{!!search}} |
|!Replace by: | {{!!replaceby}} |

---

!First step
!!//Apply the new tag to the following tiddlers//
<$list filter="[!has[draft.of]tag{!!search}!tag{!!replaceby}sort[created]]">
<$checkbox tag={{RenameTags!!replaceby}}><$link to={{!!title}}><$view field="title"/></$link></$checkbox>
</$list>

!Second step
!!/
/Remove the old tag from the following tiddlers//
<$list filter="[!has[draft.of]tag{!!search}tag{!!replaceby}sort[created]]">
<$checkbox tag={{RenameTags!!search}}> ~~<$link to={{!!title}}><$view field="title"/></$link>~~</$checkbox>
</$list>




Stephan Hradek

unread,
Jan 14, 2014, 12:05:28 PM1/14/14
to tiddl...@googlegroups.com
I'm really flabbergasted!

That's really great stuff!
Message has been deleted

Stephan Hradek

unread,
Jan 14, 2014, 12:47:13 PM1/14/14
to tiddl...@googlegroups.com
There was a mistake in the first one I posted… So here is the real enhancement where you do not need to edit the tiddler to change the tags you want to search:


|!Search tag: | <$edit-text tiddler="$:/temp/RenameTags/search" tag="input" type="text"/> |
|!Replace by: | <$edit-text tiddler="$:/temp/RenameTags/replace" tag="input" type="text"/> |


---

!First step
!!//Apply the new tag to the following tiddlers//
<$list filter="[!has[draft.of]tag{$:/temp/RenameTags/search}!tag{$:/temp/RenameTags/replace}sort[created]]">
<$checkbox tag={{$:/temp/RenameTags/replace}}><$link to={{!!title}}><$view field="title"/></$link></$checkbox>

</$list>

!Second step
!!/
/Remove the old tag from the following tiddlers//
<$list filter="[!has[draft.of]tag{$:/temp/RenameTags/search}tag{$:/temp/RenameTags/replace}sort[created]]">
<$checkbox tag={{$:/temp/RenameTags/search}}> ~~<$link to={{!!title}}><$view field="title"/></$link>~~</$checkbox>
</$list>



Message has been deleted

Stephan Hradek

unread,
Jan 14, 2014, 2:10:20 PM1/14/14
to tiddl...@googlegroups.com
I hope it is okay for you that I included this great trick in my http://tw5magick.tiddlyspot.com collection.

Jeremy Ruston

unread,
Jan 14, 2014, 3:22:42 PM1/14/14
to TiddlyWiki
HI Alberto

That is indeed very cool, I'm impressed at your ingenuity.

It's interesting that you describe yourself as a non-programmer: an important goal for TiddlyWiki is to lower the barriers to some of the things that developers can do easily and take for granted. My hope is that TiddlyWiki provides a rich enough set of primitives that it has some of the generative characteristics of a program, but feels less procedural to a user.

Many thanks,

Jeremy



On Tue, Jan 14, 2014 at 7:10 PM, Stephan Hradek <stephan...@gmail.com> wrote:
I hope it is okay for you that I included this great trick in my http://tw5magick.tiddlyspot.com collection.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Albertononi

unread,
Jan 16, 2014, 7:59:59 AM1/16/14
to tiddl...@googlegroups.com
@Stephan: I'm glad you found the trick useful and shared it with others.

@Jeremy: As a philosopher, my programming background is as low as the floor, but I enjoy very much using TW and tweaking what others do for my own use. Thank you very much for such a great piece of software!

I've uploaded my new TW5 to tiddlyspot: http://tesis.tiddlyspot.com/ so others can see and get ideas from it.

Stephan Hradek

unread,
Jan 16, 2014, 8:10:56 AM1/16/14
to tiddl...@googlegroups.com
This seems french to me ;)

Small tipp: Try in your "Définitions" tiddler this instead of putting a Level 3 header. Maybe you like it?

<$list filter="[tag[.définition]tag[Fonctions]sort[title]]">

<<< <$link to={{!!title}}><$view field="title"/></$link>
<$transclude/>
<<<
<hr></$list>


Albertononi

unread,
Jan 16, 2014, 10:01:01 AM1/16/14
to tiddl...@googlegroups.com
Danke schön Stephan! but I prefer to have the source of the definition more visible.

Stephan Hradek

unread,
Jan 16, 2014, 12:50:01 PM1/16/14
to tiddl...@googlegroups.com


Am Donnerstag, 16. Januar 2014 16:01:01 UTC+1 schrieb Albertononi:
Danke schön Stephan! but I prefer to have the source of the definition more visible.

That could be done with CSS tweaking. THe advantage is that the "cite" is also tagged as a <cite>.

vpl

unread,
Feb 28, 2014, 3:08:16 AM2/28/14
to tiddl...@googlegroups.com
Hi Guys 

Thanks a lot for this bunch of answers.
I've tested the solution on TW5 Magick and that works like a charm ..!

Thanks a l.ot

Regards

vpl

Novbert

unread,
Mar 27, 2014, 5:31:17 AM3/27/14
to tiddl...@googlegroups.com
It works like a charm! Thanks a lot for this!
I'm just wondering if the same could be done somehow for in-wiki links also.

Gerald Strickland

unread,
Sep 30, 2014, 12:33:46 PM9/30/14
to tiddl...@googlegroups.com
@Alberto Molina This is simply beautiful. Thank you!

Captain Packers

unread,
Nov 21, 2014, 5:12:31 PM11/21/14
to tiddl...@googlegroups.com
Slick. Thanks.

Tobias Beer

unread,
Nov 21, 2014, 6:05:42 PM11/21/14
to tiddl...@googlegroups.com
Hi Alberto,
 
I've uploaded my new TW5 to tiddlyspot: http://tesis.tiddlyspot.com/ so others can see and get ideas from it.

Did you develop the flavor yourself? ...let alone gather and read all the actual contents on top?
I love your wiki, it's quite interesting in all regards, TiddlyWiki or otherwise.

It's quite hilarious how an empty reference is displayed with lorem ipsum. ^_^

Best wishes, Tobias.

Alberto Molina

unread,
Nov 22, 2014, 2:07:16 AM11/22/14
to tiddl...@googlegroups.com
Hi Tobias,

Yes, I did it all myself, thanks to the community here.

Alberto

Leopold Bloom

unread,
Nov 30, 2017, 1:22:01 AM11/30/17
to TiddlyWiki
I was able rename a bunch of tags today with your code (used the version from TW5 Magick). It was a trivial change - tag capitalisation. It would have been tedious to change each by hand. I thought the Tag Manager will be able to do this natively (v 5.1.14), but no luck and while searching for a solution, your post was the first hit. Thank you.

A question to others: Is this the best way to rename tags, any chance this feature coming to Tag Manager?

PMario

unread,
Nov 30, 2017, 4:16:21 AM11/30/17
to TiddlyWiki
On Thursday, November 30, 2017 at 7:22:01 AM UTC+1, Leopold Bloom wrote:
I was able rename a bunch of tags today with your code (used the version from TW5 Magick). It was a trivial change - tag capitalisation. It would have been tedious to change each by hand. I thought the Tag Manager will be able to do this natively (v 5.1.14), but no luck and while searching for a solution, your post was the first hit. Thank you.

A question to others: Is this the best way to rename tags, any chance this feature coming to Tag Manager?

You may be interested in the tiddler manager: https://tiddlywiki.com/#%24%3A%2FManager 

It can do some more things.

have fun!
mario
Reply all
Reply to author
Forward
0 new messages