Skip to content

Instantly share code, notes, and snippets.

@mikey179
Created April 7, 2012 15:25
Show Gist options
  • Save mikey179/2329713 to your computer and use it in GitHub Desktop.
Save mikey179/2329713 to your computer and use it in GitHub Desktop.
Convert trac wiki export directory to mediawiki format
<?php
# uses trac2mediawiki perl script from http://www.mediawiki.org/wiki/Extension:TracWiki2MediaWiki#Code
$dirit = new DirectoryIterator(getcwd());
foreach ($dirit as $file) {
if (!$file->isFile() || substr($file->getFilename(), 0 , 1) == '.' || $file->getExtension() == '.md') {
continue;
}
$output = array();
$result = null;
echo 'perl convert.pl ' . $file->getFilename() . "\n";
exec('perl convert.pl ' . $file->getFilename(), $output, $result);
if (0 != $result) {
die('Failure converting ' . $file->getPathname() . "\n" . join("\n", $output));
}
rename($file->getPathname() . '.after', str_replace('%2F', '-', $file->getPathname()) . '.mediawiki');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment