Is there a way to rename a page through DokuWiki?
Renaming would possibly break a lot of links linking to the old page. Since DokuWiki doesn't know which pages link where this cannot be handled by DokuWiki. An easy way to “rename” a page is to simply create the new one and then change the content of the old page to something like this:
moved to [[newpage]]
Then visit the pages linking to the old page, and update them to refer to the new page. This can be done gradually.
Note that the old revisions will not be moved with that page. If you like to move them too, you should either write a script or use the plugin (see below).
You can also rename/move the txt files in the file system, and the gz files in the attic. This will break links and metadata.
The pagemove plugin allows a simpler way for an administrator to move/rename pages.
The pagemove plugin does not work currently and produces a lot of unwanted changes!
Note: This tip assumes one is using a Unix-like OS with text file utilities installed, or is using Cygwin under Windows.
Note that following this tip prevents DokuWiki from keeping a coherent page history (old revisions). Remember to back up all raw text files and data.
How-To Rename a set of pages? Use sed regular expressions to match a filename pattern and replace it with a new filename pattern.
This is example is bad. See why you should never parse LS for details.
Example: Rename all pages starting with <project_name> to another prefix:
for f in `ls *.txt`; do sed -e 's:\[\[project_name\(.*\)\]\]:[[prj_code.\1]]:g' $f > $f.new; done for f in `ls *.new | sed -e 's:\(.*\)\.new:\1:g'`; do mv $f.new $f; done for f in `ls *.txt | sed -e 's:project_name\(.*\)\.txt:\1.txt:g'`; do mv project_name-$f prj_code-$f; done
Better:
find . -name '*.txt' -exec sed -e 's:\[\[project_name\(.*\)\]\]:[[prj_code.\1]]:g' '{}' > '{}'.new \;
find . -name '*.new' -exec sed -e 's:\(.*\)\.new:\1:g'`; do mv '{}'.new '{}' \;
find . -name '*.txt' -exec sed -e 's:project_name\(.*\)\.txt:\1.txt:g'`; do mv project_name-'{}' prj_code-'{}' \;
Explanation:
Noob questions - I believe using the above script code is a replacement for the “in the filesystem” method, plus it handles all the backlinks, right? The meta data would still be broken? Is that important? (I personally don't care about history, but for completeness would be good to address that). This example seems to be for renaming a namespace, would it also work for renaming the .txt files themselves? If these questions are inappropriate here, my apologies - feel free to delete them, but if you're feeling magnanimous please address the issues in a reply here: http://forum.dokuwiki.org/thread/7677 Thanks.