Import Moveable Type Export File into Textpattern
18 December 2004, early afternoon
I’ve modified the Wordpress Moveable Type import script so that it will import posts, comments, and primary categories from a moveable type export file into a textpattern database. I think that under the GNU license my changes are OK.
To say it hasn’t been thoroughly tested would be an understatement. It worked on my computer at home. So please backup your database before using it, just incase it munges it up. You should be able to run the script multiple times, it doesn’t import duplicates.
To use the script, copy the file to your textpattern directory, rename it to mt-import.php, and browse to the file in your web browser. You’ll need to set a variable in the php file that says where the moveable type file with your exported posts is. Once the script has completed running, you need to run the You may also need to clean up the authors who were imported, fixing passwords and email addresses as needed._update.php
script to clean up the category table.
The script: import-mt.txt
Update: The script no longer applies textile rules to the titles.
Update: The script handles importing authors slightly better. If your Moveable Type author name, and the name you supplied to Textpattern match, you shouldn’t experience problems importing authors.
Update: The script handles importing authors slightly better. If your Moveable Type author name, and the name you supplied to Textpattern match, you shouldn’t experience problems importing authors. This won’t help people who’ve already used the script.
Update May 15th: I fixed a bug which would spit out a bogus error after a new author was inserted into the database.
*Update May 16th:* This script will fail spectacularly if you specify a table prefix when setting up textpattern.
Update May 16th: If applying textile to your old MT posts is just going to munge them up, then replace line 200, $body_html = $textile->textileThis($post_content);
with $body_html = $post_content;
Update June 1st: The script no longer reports a mysql error when inserting categories (they were being inserted properly, but the check to see they were inserted was wrong.) The script now works with table prefixes.
Update Dec 18th: The script no longer requires you run _update.php
after you have imported your entries. It will rebuild the category tree when it is done importing by itself now. I’ve also tested importing to a RC1 install.
Update Aug 29th 2005: This script is no longer needed; Textpattern can import Moveable Type installs from within the application.
and now we can ALL “import posts, comments, and primary categories from a moveable type export file into a textpattern database.”
yay the excitement! :P
by sh!ma on May 2 2004, 1:48 am #
I’m not a stranger to sarcasm.
by ramanan on May 2 2004, 2:33 am #
Do you know how to merge authors? I imported MT posts and now I have two authors named “Ry Rivard,” but one shows up only as “7” and I have two of another author, and all the other non-duplicated authors have number’s instead of names in the archive pages.
by Ry Rivard on May 7 2004, 7:11 am #
Merging Authors will require some SQL, but here is how I think you can go about fixing the problem:
First, open up the txp_users table. You will need eventually need to delete all the duplicate authors from this table. Before doing that however, note which users correspond to the same author. You should have one user you created in txp, and one user that was created by the import script. Note the RealName fields of both matching authors. The RealName field it the author id in the textpattern table.
Next, open up the textpattern table. You will need to run the following SQL query for each author you want to merge. You should have a list of the RealName entries you want to use, those that were created and assigned by textpattern, and the corresponding RealName entries that the moveable type import script made.
update textpattern
set AuthorId = [the txp assigned RealName]
where AuthorId = [the MT script RealName]
Once you have done this, all the articles you have imported will point to the correct author.
You then can erase the bad authors from the txp_users table. You must run the following SQL query
delete from txp_users
where user_id= [the MT script user id]
That should clean things up. Hope it helps. If you don’t think the above describes your problem, send me more information.
by ramanan on May 7 2004, 3:05 pm #
Hey, Ramanan. I’m going to refer people to this article, so this thing better work! ;) BTW, I take it you will make necessary changes to make it work with the impending release of 1.19?
by hass on June 1 2004, 8:25 pm #
Hopefully there won’t be too many changes to make, but yeah, I intend to keep the script up to date. And this script “works”. Heh.
by ramanan on June 1 2004, 9:01 pm #
Worked fine—thanks!
One problem through: the script created a bunch of authors, and I don’t know how to assign passwords to them.
The default password doesn’t allow me to log in as any of those authors, and when I change it to something else in the database I get the same result.
by Anark on August 12 2004, 8:59 am #
You can actually just erase all the authors if you don’t want them. The old articles should still be there, and be editable by your master account. If you can’t log in as one of the authors, make sure you are using field
name
as the login name.by ramanna on August 12 2004, 11:03 pm #
I want to migrate the authors rather than delete them.
The “name” and “RealName” fields contain the same values, so I’m sure I didn’t try the wrong login names.
What’s funny, too, is that the password listed in the database for my “Publisher” account isn’t the password I use to log into TextPattern; it’s the password I use to log into my hosting account.
by Anark on August 13 2004, 1:18 am #
Wait—it’s weirder. The publisher account password in the database isn’t anything I’ve seen anywhere. Yet I can log in with the publisher password I actually chose.
by Anark on August 13 2004, 2:43 am #
Thanks for the script it worked like a charm. However when I run _update.php I’m receiving this error:
Fatal error: Call to undefined function: safe_delete()
Any idea what I’m doing wrong?
by Mike on December 11 2004, 8:57 pm #
Not a clue. That script is written by Dean. If you are using a newer version of Textpattern perhaps you don’t need to run it anymore?
by ramanan on December 11 2004, 9:49 pm #
Ramanan – great script. However, I’ve come across one tiny flaw (although I may be the one at fault, I’m not sure).
Somewhere along the line there’s an assumption that all the comments and posting times are either in UTC or at the server’s local timezone.
So whenever I then import these to my new Txp blog (which is at +13 to the TextDrive servers on UTC) they’ll have the the times listed in the rendered pages at 13 hours ahead of when they were actually posted.
Is there some SQL that might fix this (it’s outside my very limited SQL knowledge)?
by Alan on December 16 2004, 9:48 pm #
I’m not sure off the top of my head, but if you post to the thread at the Text Patter forum I’m sure you’ll get a response. I suspect you can probably just add 13 hours to the time, but I’ll need to experiment first. Also, I’ll update the script if it is indeed importing things incorrectly.
by ramanan on December 16 2004, 10:23 pm #
Thanks – I posted there, then eventually figured it out myself. Details here.
by Alan on December 19 2004, 3:49 am #
I wonder if it is actually a Textpattern bug. I was under the impression Textpattern would add the time offset to any dates before displaying the date. I had to do this myself for my friendly time plugin.
by ramanan on December 19 2004, 1:54 pm #