Two years is not such a long time

I used to have a blog, but I stopped writing two years ago. I’m going to try to start again, and my first step is switching from MovableType to WordPress by mostly following Tony’s example. I also convinced Karen to switch too, by moving her blog so she didn’t have much choice.

I needed to perform the same Kwiki format cleanup that Tony did, but I wanted a different permalink structure: I prefer the date and name based option in WordPress. So I didn’t need to hack the WordPress import script or worry about matching IDs. Instead I needed to generate a list of redirects, one for every blog entry. I wrote a short Perl script to create the list from the Movable Type export:

#!/usr/bin/perl
use strict;

my $user = shift or die "usage: $0 user\n";

local $/ = "--------\n";

while(<>) {
  my ($id) = /^ID: (\d+)/m;
  $id = sprintf "%06d", $id;
  my ($title) = /^TITLE: (.*)$/m;
  $title = lc $title;
  $title =~ s/\s+/-/g;
  $title =~ s/[^\w-]//g;
  my ($m,$d,$y) = m{^DATE: (\d+)/(\d+)/(\d+)}m;
  print "Redirect permanent /$user/archives/$id.html
    http://martian.org/$user/$y/$m/$d/$title\n";
}

1 comment so far ↓

#1 Khaos » Blog Archive » New Blog Software on 03.06.06 at 23:00

[...] I haven’t written much in my blog this year. I’m going to blame this on the fact that I was ill for most of January and February. Now that I feel like blogging again I am going to have to learn to use new blogging software. I have been using Moveable Type for over two years but whilst I was ill Marty and Tony decided to move all our blogs to Wordpress. I had asked Marty not to move my blog as I don’t really like change but he ignored me. Wordpress must be fairly easy to use as the only problem I’ve had so far has been getting the password out of Marty. Well I did manage to mess up. It seems that I published a blank entry by mistake. I’ll need to work out how to get rid of that and see if I can publish this instead! [...]

Leave a Comment