faq:howto-rename-pages
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
faq:howto-rename-pages [2014-04-01 22:33] – [Using a Plugin] Klap-in | faq:howto-rename-pages [2022-07-02 19:18] (current) – old revision restored (2016-10-08 23:58) andi | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== HOWTO: Rename Pages ====== | ====== HOWTO: Rename Pages ====== | ||
- | :?: Is there a way to rename a page DokuWiki? | + | :?: Is there a way to rename a page in DokuWiki? |
- | + | ||
- | + | ||
- | ===== The easy way ===== | + | |
- | + | ||
- | Renaming would possibly break a lot of links linking to the old page. Since DokuWiki doesn' | + | |
- | + | ||
- | Moved to [[newpage]]. | + | |
- | + | ||
- | Then visit the [[: | + | |
- | + | ||
- | 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 a plugin (see below). | + | |
- | + | ||
- | + | ||
- | ===== On the file system ===== | + | |
- | + | ||
- | 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. | + | |
===== Using a Plugin ===== | ===== Using a Plugin ===== | ||
- | The [[plugin: | + | The [[plugin: |
===Old plugins=== | ===Old plugins=== | ||
- | * The [[plugin: | + | For historical references: |
+ | * The [[plugin: | ||
* The [[plugin: | * The [[plugin: | ||
- | ===== Using UNIX commands | ||
- | **Note**: This tip assumes one is using a Unix-like OS with text file utilities installed, or is using Cygwin under Windows. | + | ===== Just copy & delete page ===== |
- | Note that following | + | Renaming would possibly break a lot of links linking to the old page. Since DokuWiki doesn' |
- | How-To Rename a set of pages? | + | Moved to [[newpage]]. |
- | Use sed regular expressions | + | |
- | This is example is bad. See [[http://mywiki.wooledge.org/ | + | Then visit the [[:backlinks|pages linking to the old page]], and update them to refer to the new page. This can be done gradually. |
- | Example: Rename all pages starting | + | Note that the old revisions will not be moved with that page. If you like to move them too, use a plugin. |
- | for f in `ls *.txt`; do sed -e ' | + | |
- | for f in `ls *.new | sed -e ' | + | |
- | for f in `ls *.txt | sed -e ' | + | |
- | Better: | ||
- | find . -name ' | ||
- | find . -name ' | ||
- | find . -name ' | ||
- | Explanation: | + | ===== On the file system ===== |
- | * The first command uses sed to find all occurrences of a DokuWiki FreeLink that starts with %%project_name%% and replaces them with a new FreeLink that is like the old one except that instead of prefix %%project_name%% it has prefix %%prj_code%%. | + | |
- | * The second command is used to replace the old raw text files (with old FreeLink) with the new raw text files (with new FreeLink). | + | |
- | * Finally, the third command renames the files that match those FreeLinks, by replacing the prefix %%project_name%% with prefix %%prj_code%% in their filename. | + | |
- | ----------------------------------- | + | You can also rename/ |
- | Noob questions - I believe using the above script code is a replacement for the "in the filesystem" | + | >:?: Break links? I assume this mean the old link have to update manually |
- | + | ||
- | ------------------------------------ | + | |
- | Here's a simple script to rename any page/ | + | |
- | + | ||
- | ==== Using a Script ==== | + | |
- | FIXME This script is **very dangerous!** | + | |
- | There no checks on valid input and the perl subsitute commands can change page content throughout the whole wiki! | + | |
- | What if we change a file named // | + | |
- | + | ||
- | + | ||
- | # vi rename_page | + | |
- | + | ||
- | + | ||
- | <code> | + | |
- | #! /bin/ksh | + | |
- | + | ||
- | cd / | + | |
- | + | ||
- | O=$1 | + | |
- | N=$2 | + | |
- | + | ||
- | + | ||
- | #-- Moving a name space | + | |
- | if echo " | + | |
- | then | + | |
- | OPATH=" | + | |
- | NPATH=" | + | |
- | + | ||
- | find * -type d | grep -w " | + | |
- | do | + | |
- | NDIR=" | + | |
- | mkdir -p ${NDIR} | + | |
- | [[ -d ${NDIR} ]] && mv ${ODIR}/* ${NDIR}/ | + | |
- | done | + | |
- | + | ||
- | #-- Moving a file | + | |
- | else | + | |
- | find * -type f -name " | + | |
- | do | + | |
- | NFILE=" | + | |
- | mv " | + | |
- | done | + | |
- | fi | + | |
- | + | ||
- | find * -type f -exec grep -wl " | + | |
- | do | + | |
- | perl -i -pe " | + | |
- | done | + | |
- | </ | + | |
- | + | ||
- | === Renaming a page === | + | |
- | Now let's rename ALL pages and links with the pattern dog_lover in their name to k9_lover. | + | |
- | # chmod 700 rename_page | + | |
- | # rename_page dog_lover k9_lover | + | |
- | + | ||
- | If the file name has a space or other special charater | + | |
- | # rename_page "dog lover" "k9 lover" | + | |
- | + | ||
- | Only got-cha is the ALL references in ANY file to dog_lover will now read k9_lover. | + | |
- | + | ||
- | === Renaming a namespace === | + | |
- | To move a name space, assuming / | + | |
- | # rename_page ns1:ns2 n3:n4 | + | >About **losing metadata**, [[..:metadata|see here]] (bottom page). |
faq/howto-rename-pages.1396384395.txt.gz · Last modified: 2014-04-01 22:33 by Klap-in