Replace content
Last modified by Vincent Massol on 2021/03/18 11:28
Replace some content string with another string |
Type | |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
{{velocity}}
#set ($search = "some word")
#set ($replacement = "other word")
#set ($xwql = "where doc.content like :search and doc.fullName <> :current")
#foreach ($item in $services.query.xwql($xwql).bindValue('search', "%${search}%").bindValue('current', $doc.fullName).execute())
#if ($request.confirm == "1")
#set ($itemDoc = $xwiki.getDocument($item))
$itemDoc.setContent($itemDoc.getContent().replaceAll($search, $replacement))
$itemDoc.save("Replaced '${search}' by '${replacement}'")
* [[$item>>$item]] replaced!
#else
* [[$item>>$item]]
#end
#end
[[Replace "$search" by "$replacement">>||queryString='confirm=1']]
{{/velocity}}
#set ($search = "some word")
#set ($replacement = "other word")
#set ($xwql = "where doc.content like :search and doc.fullName <> :current")
#foreach ($item in $services.query.xwql($xwql).bindValue('search', "%${search}%").bindValue('current', $doc.fullName).execute())
#if ($request.confirm == "1")
#set ($itemDoc = $xwiki.getDocument($item))
$itemDoc.setContent($itemDoc.getContent().replaceAll($search, $replacement))
$itemDoc.save("Replaced '${search}' by '${replacement}'")
* [[$item>>$item]] replaced!
#else
* [[$item>>$item]]
#end
#end
[[Replace "$search" by "$replacement">>||queryString='confirm=1']]
{{/velocity}}