Create journal entries out of a single draft

Hi folks,

I have a document that looks like this:

## 2020-08-09

Blah blah blah.

## 2020-08-10

Lorem ipsum.

## 2020-08-11

Foo bar.

I would like to create an action that takes this document and creates three files in Dropbox, the first of which would be entitled 2020-08-09.md and look like this:

## 2020-08-09

Blah blah blah.

I’ve done a bit of customizing with Drafts, mostly using the built-in features.

In this case, I need some help figuring out how to reliably parse the document and create the Dropbox files. If the community can point me to scripts that do similar things, I can probably cobble together what I need.

Try this.

let dbx = Dropbox.create();
let astrSections = draft.content.split("## ");

astrSections.forEach(function(strSection)
{
	if(strSection.length > 0) dbx.write("/" + strSection.split("\n")[0] + ".md", "## " + strSection, "add", true);
});
1 Like

Thank you so much Stephen, this does exactly what I asked for! I tweaked your script a bit to adjust the folder, filename and to remove extra \n at the end. I use this to archive my notes from Bullet Journal. I type them up once a month and with this script can save them in individual Markdown files for later reference.

1 Like