Sunday, July 10, 2011

Transferring a blog from Typepad to Blogger

I am sometimes asked to work on technology stuff around the house.  Surprise, surprise.  Today my wife asked me to help her transfer her blog from Typepad to Blogger/Blogspot.  I haven't fooled with blogging at all except for once before when there was some trouble with getting her Typepad blog started.  I only recall that is was a lot harder than I thought I should have been.  Lots of scripting, Linux/Web server stuff... I don't know how non-IT types get it done, as it was a real challenge for me.  Well, today I had another challenge on my hands.

She is adventurous enough to have taken the task as far as she could take it.  She was at a point where she had exported her Typepad blog posts (in an .mht file) and was trying to download the Google blog converter to convert that file to a Moveable Type file (.mt) so that the blog posts could be imported into Blogger.  Seems pretty simple, but there were several challenges.

The download file from Google's blog converter was a .gz file, and the computer where my wife blogs had no program to handle that type of archive.  I downloaded a 40-day trial of  WinRAR to handle this task, and then extracted the folder structure from the Google download file and stored it in a temporary location on the computer.  I then set about trying to use the converter.

The converter has sparse documentation but I did find a .\lib folder that has some batch files in it.  I used the one called movabletype2blogger.bat but it had errors.  Turns out I had to download and install Python (I used version 2.7).  I still received errors because the paths in the bat file were all wrong.  I pretty much hardcoded all the variable paths that the file's author had tried to make.  Here is the batch file that finally worked for me.  Note that I had installed Python into its default folder, \python27.

set PYTHONPATH=c:\python27
set BASEPATH=c:\temp\google-blog-converters-r89
set PYTHONPATH=%PYTHONPATH%;%BASEPATH%\lib
c:\python27\python "%BASEPATH%\src\movabletype2blogger\mt2b.py" %1

I continued to receive errors until I renamed the Typepad file from .mht to .mt. 

The command that I finally used was movabletype2blogger typepad-export-file.mt. run form a Command prompt, of course.  (I had to navigate to the C:\temp\google-blog-converters-r89\bin folder, first).

This produced several seconds worth of scrolling text down the computer screen because the script output was to "stdout", so I simply redirected the output to a file, like this:

movabletype2blogger typepad-export-file.mt > import-to-google.xml

A quick look at the .xml file showed that the file contained blog posts.  Success!  Seems like I'd almost be finished at this point, but no... the .xml file produced some mysterious error message with no explanation when I tried to import it into Blogger.  After some trial and error I was able to pare down the .xml file to a single post and did import it successfully.  To do so I opened a copy of the .xml file in notepad and searched for "ns0:entry" (for the beginning of a post) and "/ns0:entry" (for the end of a post).  I had to leave "</ns0:feed>" at the bottom, but I found the first "/ns0:entry" and deleted everything between it and the the "/ns0:feed" tag.  I then proceeded to use the same process to import additional posts, one at a time at first -- then several at a time.  At one point near the end of the 120+ posts the imports began failing.  I finally determined that the export from Typepad or the conversion process had placed all the comments (where people had commented on the blog posts) at the end of the .xml file, and these would not import. 

So after all that my wife's blog was up and running, but no comments from her Typepad blog were brought over.  The blog's pictures still pointed to her Typepad blog, so she had to re-point those to a different location for the pictures before she took down that blog.  There were also some minor formatting quirks that she had to work on (extra line breaks and such), but those were simply aesthetic.

So, with all that blog "piping" experience I thought I'd start up a blog and write about the experience.  Let me know if this helps you!

No comments:

Post a Comment