psst.. this blog is on hiatus.

HTML->MT via the magic of Perl

622 “new” entries. I tired of having my old jotsheet entries (pre-October 2003) in flat files, so I wrote a Perl script to parse the HTML (which was more or less predictable) and format it for Movable Type importing.

A couple of recommendations if you’re interested in a similar homebrew conversion from flat files to MT:

  1. Create a new blog and do everything there. Don’t mess up your current one.
  2. If at all possible, retain the dates (and times, if possible) of your old entries and bring that into MT. The entry is just slightly more important than its date. :)
  3. Close comments on old entries. A crapload of old entries that can be commented upon is a comment spammer’s dream.
  4. Attempt to use the same templates for your normal blog and your import/old blog.
    • Use the Compare plugin to maintain sufficiently general templates.
    • If you’ve not already done so, move your templates to associated files, not simply text in the template <textarea>.
    • Associate your templates with symlinks (ln -s [source] [link]) or hardlinks (ln [source] [link]) on the file system.
  5. Delete superfluous templates, such as the Atom, RSS, and RDF templates (your old blog will not grow); category archive template (unless you import categories); and main and archive templates (that can be handled by your regular blog). I have two templates in my “old jotsheet” blog: date-based archive, and individual archive.
  6. Make sure that you redirect all broken links via .htaccess. Monitor your site logs for a few days after you complete your conversion to see what’s broken. It helps if index your site locally for searching—then you’ll see all the broken links pop up.

If you’d like to take a look at the crappy Perl script I wrote to convert flat file HTML files to MT’s format, feel free: jotsheet_conversion-pl.txt. Be forewarned: it’s the first Perl script I’ve ever written, and yes, it’s a trainwreck.

One Response to “HTML->MT via the magic of Perl”

  1. 1
    Muse Ik Says:

    Hey whattup?! I need your help. How the heck do I convert from M4P (iTunes) to an MP3? Dude, post a message on this in your AWESOME blog. PS I can’t wait to move out of Chicago.