cogProvides a UI to rename tags from the wiki
Developed by

Bruno Neves

0 Votes
LicenseGNU Lesser General Public License 2.1


An equivalent feature is available in XWiki. See the Tag Application.

This snippet will let you rename all the tags with a specific name at once.

Follow these steps:

  • Create a new wiki page
  • Edit it and save it with the present code
  • Insert the name of the tag you want to change
  • Insert the new name
  • Submit


1 Rename Tags

<form name="input" action="$xwiki.getURL("Main.Rename Tags""view")" method="get">
   Tag to replace:
   <input type="text" name="tag1">
   New tag:
   <input type="text" name="tag2">
   <input type="submit" value="Submit">

[All Tags>Main.Tags]

#set ($tagToReplace = "")
#set ($newTag = "")

#if ($request.tag1)
    #set ($tagToReplace = $request.tag1)
    #set ($newTag = $request.tag2)

    #set ($taggedDocs = $xwiki.searchDocuments(", BaseObject obj where and obj.className='XWiki.TagClass'"))
                #foreach ($taggedDocName in $taggedDocs)
                    #set ($taglist = "")
                    #set ($taggedDoc = $xwiki.getDocument($taggedDocName))
                    #set ($taglist = $taggedDoc.getObject("XWiki.TagClass").get("tags"))
                    #if ($taglist.contains($tagToReplace)) $taggedDoc.getObject("XWiki.TagClass").set("tags", $taglist.replaceAll("(^| +)$tagToReplace( +|$)", "$1$newTag$2"))
                       * [$taggedDoc.fullName] : replacing tag "$tagToReplace" by "$newTag"
                        #set ($discard = $



Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Created by Bruno Neves on 2008/09/08 14:16

Get Connected