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?
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?
Best answer: Here's a quick solution:
Search for:
posted by Aaorn at 5:51 AM on July 13, 2004
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.You can specify a forced Author and Category from the Import screen within MT, or you can add that information to the regex.
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.
-----
--------
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
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
posted by Aaorn at 7:11 AM on July 13, 2004
This thread is closed to new comments.
posted by Aaorn at 4:52 AM on July 13, 2004