Rename Space Snippet

Rename Space Snippet

Rename all pages in a space. To use this script copy its source to a page in your wiki and save it (make sure you choose XWiki Syntax 1.0 as the syntax for the page since the script below is in XWiki Syntax 1.0).

Code

1 Rename space

#if($request.from && $request.to)
1.1 Renaming ~~$request.from~~ to ~~$request.to~~
  #foreach($item in $xwiki.getSpaceDocsName($request.from))
    * Renaming $item $xwiki.getDocument("${request.from}.${item}").rename("${request.to}.${item}")
  #end
#end

<form action="" method="get">
<div>Source space: <select name="from">
  <option value="">please select</option>
#foreach($space in $xwiki.getSpaces())
  <option value="$xwiki.getXMLEncoded($space)">$xwiki.getXMLEncoded($space)</option>
#end
</select>
</div>
<div>Target name: <input name="to" value=""/>
</div>
<div><input type="submit" value="Rename"/></div>
</form>
Tags:
Created by VincentMassol on 2007/09/24 17:09
Last modified by Vincent Massol on 2009/12/18 09:41

This wiki is licensed under a Creative Commons license
2.2.1.27354