Thought I’d outline a bit of what I did to get all my posts and tags migrated from LiveJournal to WordPress 2.7.1. Note that this information will be redundant soon enough — there’s much better LJ import support in the latest WordPress trunk. It’ll even pull in your ‘Current Music’ and ‘Current Mood’ fields, which I couldn’t do. :-(

Some background first. LiveJournal lets you export your blog posts one month at a time. You can feed these files to the WordPress LiveJournal importer. I’ve been blogging there since December 2003, so that was definitely not an option. Some digging around eventually brought me to ljdump. This is a really nifty tool, even if you just want to back up all your posts. It dumps your data into a large set of XML files, which you can collate with the convertdump.py script for uploading to the WordPress LiveJournal importer.

There was one hiccup here — a lot of the XML files corresponding to my earlier posts (at least) had an extraneous ASCII character 4 at the end of some lines. I had to use a simple for i in /*xml; do sed -i -e s:$'\004':: before using convertdump.py, and things were back on track (sed ftw!). I used the script to make one big XML file with all my posts, and fed it to the LJ importer, and all my posts were in.

But my tags, unfortunately, were not. ljdump happily pulls the tags from LiveJournal, but the importer just ignores them. I found a sort-of patch to fix this, but it seems to be quite antiquated. Based on this and the WordPress importer (that’s the importer that allows WordPress to import from another WordPress blog’s exported output), I wrote my own patch to import LJ tags (against WordPress 2.7.1). Just cd into your blog directory and do a patch -p0 < wp-livejournal-import-tags.patch to use it.

That’s it — I dropped all the old posts (requires a plugin to do it all at one shot), and then imported the big XML file again, and voila!

Trivial as it was, it was great to see how easy hacking the WordPress code was. There’s more to come in days ahead. I hope it remains this easy. :D

Update: Just noticed that the imported comments are not threaded. This kind of blows, because there have been some really long threads on some posts. I guess I’ll wait till the new WordPress goes stable and do a re-import. (file under #suckage)