Importing From B2 To Movable Type

This How-To was updated on May 6, 2003 and then again on September 4, 2003 and again on June 4 2004. Given it’s age, this information is no longer relevant. I’m keeping it up here for historical purposes.

Here’s some code I wrote after getting involved in a discussion at the MT Support Forum. If you’re a MT user and you don’t read their forums, you’re only hurting yourself!

Many WordPress users visit this page hoping to migrate to MT with the help of this script… a visitor here named “seraph” tells us that the current version of WordPress uses a slightly modified database schema which keeps my script from working as designed:

all posts in recent versions of WP have posts set to 0 in wp_posts table, and there is a separate wp_post2cat table that links post IDs with category IDs.

Until i get a spare weekend to install WordPress and rework my SQL, I’m afraid you WordPress users will need to search elsewhere for your export/import needs.

This PHP script will read your B2 CMS entry, authors, and comments tables and format them for easy importation into Movable Type. Important note: all three B2 table must exist in your database or this script will not work! Please follow these directions closely:

1. To use this script, your host must allow you to run PHP scripts. Since you’re trying to import a B2 blog, this is probably not an issue (but I thought I’d mention it anyways).

2. Click here to view this code in another window.

3. Copy and paste ALL of the code into a new file and save it as export.php on your web-server.

4. Edit export.php to reflect your database info (your host, your login, your pw, etc).

5. Open a browser window and point to your copy of export.php.

6. Select the view source option from your browser’s menus.

7. Copy the source to another file and save that file in your import directory (as described in the MT import documentation. You did read the MT documentation, right?). Name the file something catchy, like import.txt.

8. IMPORTANT: Delete the first line of the file (it should be the line that has eight dashes )

22 Replies to “Importing From B2 To Movable Type”

  1. Bill – thanks so much for posting your b2->MT instructions – they worked perfectly, first time. I had thought that I would have to trash the old b2 posts. Good stuff!

  2. For those using “WordPress”(a derivative of b2), go into export.php and search and replace “b2” with “wp_” (e.g. b2comments becomes wp_comments).

    That’s how you do an export from WordPress to Movable Type.

    What a great script, Bill! Thanks!

  3. Hi ,
    I used your hack and just want to post here that everything went too smoothly . great job. btw, i asked you wether i would need to create the categories and then import …. which you didnt remember at that time… so for any one else wanting to know that … YES , i created my old categories and ddin’t select any default category to import into … and voila , automatically the old posts got assigned to the categories they were earlier . πŸ™‚

  4. What a great script! I’m having a slight problem with it using the latest version of WordPress. It will only spit out one entry and on further investigation seems to choke on the $prev_entry variable. Any hints on how to fix it?

  5. I’m having problems importing it into MT 3.0, the new version…it’s saying it imported successfully, but the entries aren’t showing up, even after I rebuild. the /weblog location i listed is the old blog, the new blog (MT) is at /blog. thanks for any help you can give!

  6. wp users having probs, this is why:
    all posts in recent versions of WP have posts set to 0 in wp_posts table, and there is a separate wp_post2cat table that links post IDs with category IDs.

  7. Hi! I hope you can help me out here.. When I try to open up export.php in my broser I get this error:

    Warning: mysql_connect(): Access denied for user: ‘my-username@localhost’ (Using password: YES) in /home/underbar/public_html/mt/export.php on line 6
    Connetion to database failed!

  8. Okay due to this program and myself not knowing how to fix this, I found a simple way to make it work for wp users:

    1.copy the db
    2. open up b2posts and change the post cat from “0” to “1”

    it should now work.

  9. It did not work for me, either. I got a blank Notepad window upon “View Source,” and am also using WordPress, rather than b2. Has anyone had any success doing this? I changed post-category in wp_posts from 0 to 1, and that didn’t work for me either.

  10. Yeah baby. My hosting provider used B2 as the blog software of choice. I just had to move to a supported software platform. Thanks a lot for the script! It worked perfectly!

  11. Your script works beautifully πŸ™‚ I had an old b2evo database that I needed to convert. I just updated the table names and 1 field name and away it went. Thank you very much.

Comments are closed.