Importing Into MoveableType
July 13, 2004 2:19 AM   Subscribe

I'm looking to import entries from another journalling system into MT, but I lack the scripting skills necessary to convert the entries into an MT-friendly format. [Less inside. Less is more!]

These entries are stored in plaintext files, which are named after the date of the entry. There's metadata at the end of the file to tell the journalling software what's up.

As an example, this would be the contents of file 20030908:

Quisque luctus scelerisque lorem. Mauris eget est. Cras at tortor. Suspendisse facilisis pellentesque ante. Vivamus aliquet. Donec nisl. Donec arcu. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Nam quis nulla non nunc viverra euismod. Nam porta libero sed enim. Aliquam erat volutpat. Ut est eros, malesuada ut, feugiat at, accumsan sit amet, lectus.

Nam blandit ligula interdum lacus.
{title=lorem ipsum is rad, man.}
{template=main}
{datestamp=200309080741}


I need a script that will convert a directory full of these files into a format I can pull into MT. Being able to specify the author/category would also be nice, but really all I need is the entry, the title, and the date.

Is this a terribly difficult thing to code up? Should I be offering to pay someone to write it?
posted by Jairus to Computers & Internet (5 answers total)
 
  1. EditPad for PC or BBEdit for Mac.
  2. The Movable Type Import Format
  3. Regular Expressions [tutorial, self link]
Unfortunately, Dean Allen's tutorial on Textism.com -- which I point to from my subsequent tutorial -- seems to have vanished. But if you get stuck I'd be happy to help.
posted by Aaorn at 4:52 AM on July 13, 2004


Best answer: Here's a quick solution:

Search for:
(.*?)
{title=(.*?)}
{template=.*?}
{datestamp=(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})}
Replace with:
TITLE: \2
DATE: \4/\5/\3 \6:\7:00
-----
BODY:
\1
-----
--------
Running that on your sample entry in EditPad gives me back:
TITLE: lorem ipsum is rad, man.
DATE: 09/08/2003 07:41:00
-----
BODY:
Quisque luctus scelerisque lorem. Mauris eget est. Cras at tortor. Suspendisse facilisis pellentesque ante. Vivamus aliquet. Donec nisl. Donec arcu. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Nam quis nulla non nunc viverra euismod. Nam porta libero sed enim. Aliquam erat volutpat. Ut est eros, malesuada ut, feugiat at, accumsan sit amet, lectus.

Nam blandit ligula interdum lacus.
-----
--------
You can specify a forced Author and Category from the Import screen within MT, or you can add that information to the regex.
posted by Aaorn at 5:51 AM on July 13, 2004


Response by poster: When I search and replace using those strings, only the last line of the entry is ending up under BODY: for me. Using EditPad Pro Demo 5.3.2... any ideas?
posted by Jairus at 6:29 AM on July 13, 2004


You need to have "Dot matches newline?" checked in the Find panel. Otherwise it'll match, at most, one line. (Sorry to have left that out before.)
posted by Aaorn at 7:11 AM on July 13, 2004


Response by poster: Thank you so very, very much.
posted by Jairus at 5:44 PM on July 13, 2004


« Older Fear of Flying   |   Summer Job in London Newer »
This thread is closed to new comments.