Script to create folder hierarchy defined in text file

Using Devonthink Pro Office 2.0pb8

I created a database and a text file that contains the structure of the folder hierarchy that I want to use in the database. Not surprisingly, the file looks like an outline. I want to create the folder hierarchy automatically from the text file.

Any suggestions on how to approach this through a script?

I can reformat the file into anything reasonable, such as csv, tab delimited, etc.


Devonthink imports OPML outlines as folder hierarchies, so the quickest route might be to get your text outline into OPML format.

Thank you for the tip.

I used the OPML editor from to convert the text file to OPML. And I found the OPML section in the DTPO documentation.

When I invoke File/Import/Files and Folders on the OPML file, I get absolutely nothing. No hierarchy, nothing in the Inbox, no error message.

Any thoughts?

Update -------
Apparently there was some issue between the opml editor and OS X in setting the file type.

What worked:
0. Get Info to set .opml to

  1. Open a new OPML file
  2. Open the hierarchy text file in TextEdit, copy the text
  3. Paste to the OPML file
  4. Save

Now I can import the OPML file and I get the folder hierarchy, EXCEPT for the lowest level leaf of each branch which shows up as a 0 byte text file.

Almost there.

The action DT takes is a bit unexpected, but here is what happens. On importing an OPML file, each outline level in the OPML file that has a child is created as a group and the child is created as a record in that group. To force an outline level to become a group, it has to have a child. The child can have a blank name. So, this structure in an OPML file:

–One’s child
–Two’s child
----Two’s grandchild

Will result in groups for One, One’s child (because it has a blank child), Two, and Two’s child. Two’s grandchild will appear as a record under Two’s child.

Try to modify your OPML (e.g., by downloading a demo of OmniOutliner and futzing with the file to get it the way you want) then import it.

Thanks for the help. I consider this one is solved.