Simple PHP Blog To WordPress Converter v0.2.0

New features include:

  • Not unzipping files that are already unzipped.
  • HttpRoot setting for root of Simple PHP Blog for dynamic replace of base URL on embedded links.
  • Related link support. Requires modification of WP template using “the_meta()”.
  • Category support. This will be augmented with tag support later.

You can get the code from the project page on Google Code.

Simple PHP Blog to WordPress Converter works like a charm

It is done.

Version 0.1 of the converter successfully produced 845 blog entries and associated comments. You can see the handiwork right here (yes, this very page you’re reading)!

There are some teething issues:

1. The categories haven’t been done
2. Internal links (referring to posts) still point to their original location
3. The default settings for posts and comments might need polishing up

Otherwise, it was a really simple process. I created the SQL file, GZipped it, and imported the GZipped file into PHPMyAdmin.

Simple PHP Blog to WordPress Converter, Part III

Rod Austin asked me in a comment how I've gone about this small application. This is my response. I'm reposting it here for your reference.

I'm doing it in C#, in a Windows Forms app on my local machine. My main reason for doing it this way is because I'm a professional C# developer, so it's much easier. Plus, I'm able to debug the application locally, which makes my life a lot easier there too. Once it's done, I'm sure it can be ported to any language, including PHP.

The basic principle I'm using is a bastardised ORM, where I loop through the folders, unzip and parse each file, and throw the (cleaned up) results into an entity that matches the WordPress table structure. Then (the bit I haven't done yet) I will save each WP entity (post and comments) into a WP database. I'm *probably* just going to generate a MySQL-compatible script instead, which can then be run manually.

I will make the code available as open source (probably the BSD licence or something similar), and then you can tinker with it. Since I'm only building it for myself, there are a few assumptions I've made in the code, and it isn't very robust. On the bright side, it's fast. I was able to unzip, parse and convert into entities all of my 850 posts in around 3 seconds.

As a final note, for about half a day's work, I'm impressed with how easy this has been so far. Granted, it would take about a day to finish it, and probably if I applied myself, the same amount of time to copy and paste every post into a WordPress engine anyway. That's not the point, though 🙂

The shareware app that just won’t quit

ShutOff 2000 works better in Windows 7 than it does in Windows Vista. I think it's awesome. I can even run Visual Basic 6 in Windows 7 without resorting to Virtual XP.

There is a .NET version of ShutOff, and I just need to finish it. I've made a fundamental change to the way the scheduler works now, and thanks to separation of concerns, will have little impact on the rest of the product. Suffice to say though that ITS ShutOff is going to be awesome.

Once the .NET version is released, I'm open-sourcing ShutOff 2000. Should make for interesting reading (and mockery).

Simple PHP Blog to WordPress Converter

Right, I'm about halfway through my Simple PHP Blog to WordPress converter and it's looking good!

I am at the point where I can convert each file into a WP post (in a generic list). Working on comments next. Last will be the SQL script.

For it to work, you will need to download your "content" folder to a local drive. The C# app is pointed at the content folder, and is able to unzip the files if you have enabled compression, read out the contents of the blog entry, and populate the necessary equivalent entities in the WordPress structure (which is as far as I am now).

When it's finished, it will generate a single SQL script to run against a standard WordPress MySQL database to populate the appropriate tables.

Some stats: I can unzip, parse and convert 850 blog entries in around 3 seconds. I expect the SQL script generation will be even quicker than that, since all the blog entries are in a generic list.

Note to self: don't forget the images.

If I ever feel the need, I'll do a PHP version to run on the site. However, I do not feel the need at the moment. I'll probably release the code into the public domain for your enjoyment.

This blog

Right, so I've got this:

844 entries using 113,842 words stored in 421,949 bytes.
344 comments using 13,094 words stored in 75,088 bytes.

I need to convert these from Simple PHP Blog (using flat files) to some form of MySQL-based thing like WordPress, because Simple PHP Blog hasn't been updated for a while, and I think my site needs a refresh too. A rebranding exercise, if you like.

I'm actually toying with a C# app that will go through each .gz file, uncompress it, remove the awkward special formatting and replace it with proper HTML tags, and write an INSERT statement for each entry. Then I'll make it freely available.

So it's 15:06 now. How far do you think I'll get by 7pm?