It's better when it's simple

User Tools

Site Tools


Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community

Follow us on Facebook, Twitter and other social networks.

Our Privacy Policy


This is an old revision of the document!

Migration from MoinMoin to DokuWiki

Below you will find scripts in PHP and Python to facilitate the conversion process.

FIXME Are there any parameters that need to be passed to the PHP script and how is that to be done? According to the code there should be three parameters. Passed through the URL? Syntax? Can anyone help?

Another document on switching appears at


I have written a small PHP script to convert wiki pages from MoinMoin to DokuWiki syntax. It does not take care of all differences, but it worked for me.

//check comman line parameters
if ($argc != 3 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
  echo "\n  Converts all files from given directory\n";
  echo "  from MoinMoin to DokuWiki syntax. NOT RECURSIV\n\n";
  echo "  Usage:\n";
  echo "  ".$argv[0]." <input dir> <output dir>\n\n";
else {
  //get input and output directories
  $inDir = realpath($argv[1]) or die("input dir error");
  $outDir = realpath($argv[2]) or die("output dir error");
  //just print information
  echo "\nInput Directory: ".$inDir."\n";
  echo "Output Directory: ".$outDir."\n\n";
  //get all files from directory
  if (is_dir($inDir)) {
    $files = filesFromDir($inDir);
  //migrate each file
  foreach ($files As $file) {
    //convert filename
    $ofile = convFileNames($file);
    //just print information
    echo "Migrating from ".$inDir."/".$file." to ".$outDir."/".$ofile."\n";
    //read input file
    $text = readFl($inDir."/".$file);
    //convert content
    $text = moin2doku($text);
    //encode in utf8
    $text = utf8_encode($text);
    //write output file
    writeFl($outDir."/".$ofile, $text);
function moin2doku($text) {
  /* like convFileNames and more
  *   ToDo: [[Datestamp]] delete?
  *         bold and italic, what goes wrong?
  *         images
  *         Problems with newline and [[BR]]
  *         CamelCase in Heading: it will be converted
  *         Moin handles code sections without closing }}} right, DokuWiki does not     
  //line by line
  $lines = explode("\n", $text);
  foreach($lines As $line) {
    //start converting
    $find = Array(  
                  '/\[\[TableOfContents\]\]/',      //remove
                  '/\[\[BR\]\]$/',                  //newline at end of line - remove
                  '/\[\[BR\]\]/',                   //newline
                  '/#pragma section-numbers off/',  //remove
                  '/\["(.*)"\]/',                   //internal link
                  '/(\[http.*\])/',                 //web link
                  '/\{{3}/',                        //code open
                  '/\}{3}/',                        //code close
                  '/^\s\*/',                        //lists must have not only but 2 whitespaces before *
                  '/={5}(\s.*\s)={5}$/',            //heading 5
                  '/={4}(\s.*\s)={4}$/',            //heading 4
                  '/={3}(\s.*\s)={3}$/',            //heading 3
                  '/={2}(\s.*\s)={2}$/',            //heading 2
                  '/={1}(\s.*\s)={1}$/',            //heading 1
                  '/\|{2}/',                        //table separator
                  '/\'{5}(.*)\'{5}/',               //bold and italic
                  '/\'{3}(.*)\'{3}/',               //bold
                  '/\'{2}(.*)\'{2}/',               //italic
                  '/(?<!\[)(\b[A-Z]+[a-z]+[A-Z][A-Za-z]*\b)/',  //CamelCase, dont change if CamelCase is in InternalLink
                  '/\[\[Date\(([\d]{4}-[\d]{2}-[\d]{2}T[\d]{2}:[\d]{2}:[\d]{2}Z)\)\]\]/'  //Date value 
    $replace = Array(
                     '',                            //remove                                
                     '',                            //newline remove                                
                     '\\\\\ ',                      //newline
                     '',                            //remove                                
                     '[[${1}]]',                    //internal link
                     '[${1}]',                      //web link
                     '<'.'code>',                      //code open
                     '<'.'/code>',                     //code close
                     '  *',                         //lists must have 2 whitespaces before *
                     '==${1}==',                      //heading 5                        
                     '===${1}===',                    //heading 4                        
                     '====${1}====',                  //heading 3                        
                     '=====${1}=====',                //heading 2                        
                     '======${1}======',              //heading 1                        
                     '|',                           //table separator                       
                     '**//${1}//**',                //bold and italic
                     '**${1}**',                    //bold                                  
                     '//${1}//',                    //italic
                     '[[${1}]]',                    //CamelCase
                     '${1}'                         //Date value
    $line = preg_replace($find,$replace,$line);
    $ret = $ret.$line."\r\n";
  return $ret;
function convFileNames($name) {
  /* ö,ä,ü, ,. and more
  $find = Array('/_20/',
  $replace = Array('_',
  $name = preg_replace($find,$replace,$name);
  $name = strtolower($name);
  return $name.".txt";
function filesFromDir($dir) {
  $files = Array();
  while ($file = readdir ($handle)) {
     if ($file != "." && $file != ".." && !is_dir($dir."/".$file)) {
         array_push($files, $file);
  return $files;
function readFl($file) {
  $fr = fopen($file,"r");
  if ($fr) {
    while(!feof($fr)) {
      $text = $text.fgets($fr);
  return $text;
function writeFl($file, $text) {
  $fw = fopen($file, "w");
  if ($fw) {
    fwrite($fw, $text);


Based on the above PHP version, a Python script that automates the file renaming, copying and conversion business. Can do attachments moving, convert attachment code, creates namespaces based on structure in MoinMoin-Wiki. also converts some Codes of German 'Umlaute'.

Checkout files from and run:

  • ./ <pages folder of MoinMoin-Wiki> <pages folder of DokuWiki>


I've written more powerful conversion script, now it converts correctly (as I think ;-) ) all syntax from except tables (now it doesn't convert aligning and spans). You can get latest version here, just copy all code from codeblock and replace <!/code> with </code>.


Why did you switch from MoinMoin to DokuWiki? Just curious, I'm debating between the two and MoinMoin's WYSIWYG editor is very nice, and big sites like and are using MoinMoin. - posted on 1/16/2006
Because MoinMoin is not as stable as it looks like? You know the Ubuntuusers Wiki-case? - posted on 04/26/2007
I've add Perl script which convert all syntax from Please, report me all errors if you found them.
tips/moinmoin2doku.1300625072.txt.gz · Last modified: 2011-03-20 13:44 by glen