Emacs To Media

#!/usr/bin/perl #


# This file is ungoverned by the Cypherpunks' Anti-License.
# Do with it as you will.

# This routine was made for the purpose of migrating a wiki
# from EmacsWiki to media wiki.
# It is a work in progress.
# Next step for me LorraineLee is to transulate
# wikilinks of the redirective or aliased kind.


my($wikidir)="$ENV{'HOME'}/Wiki";
my($newdir)="$ENV{'HOME'}/MediaWiki";

mkdir($newdir,0777);
opendir(DIR,$wikidir);
opendir(DIR2,$newdir);

@files=readdir(DIR);
foreach (@files) {
    open(PHILE,"<$wikidir/$_");
    open(PHILE2,">$newdir/$_");
    @lines=<PHILE>;

    foreach (@lines) {
# translate external links:
	$_ =~ s/\[\[(.*)\]\[(.*)\]\]/'['.$1.' '.$2.']'/eg;
# translate internal links:
	$_ =~ s/([A-Z][a-z]+([A-Z][a-z]+)+)/'[['.$1.']]'/eg;
	$_ =~ s/([a-z])([A-Z])/$1.' '.$2/eg;
	$_ =~ s/(\[\[.*\]\])/lc($1)/eg;
	print PHILE2;
    }
    close PHILE;
    close PHILE2;
}

closedir(DIR);
closedir(DIR2);

# 
Hosted by www.Geocities.ws

1