Created
April 7, 2012 15:25
-
-
Save mikey179/2329713 to your computer and use it in GitHub Desktop.
Convert trac wiki export directory to mediawiki format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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