Request for Assistance - Action to Organize News Items in Drafts and Obsidian

Hello everyone,

I am reaching out to the community for help with creating a Drafts action that can streamline my workflow involving news items that I’ve stored as drafts. The drafts are all written in Markdown and tagged with “news items.” I am looking for a way to automate the process of transferring these drafts into my Obsidian vault, specifically to the location “Vault/Articles/News” on my iPad’s local storage.

Here is what I am envisioning for the action:

  1. Identify and select all drafts within the Drafts app that are tagged with “news items.”
  2. For each selected draft, extract the first line that features an h1 Markdown tag (e.g., # Title) and use this as the filename for a new Markdown file in my Obsidian vault.
  3. Save the remainder of the draft content as the body of this new Markdown file, excluding the first line that has been used as the title.
  4. Place each newly created Markdown file into the “Vault/Articles/News” folder in my Obsidian vault on my iPad’s local storage.

Unfortunately, I do not have experience with JavaScript and would greatly appreciate any guidance or assistance in constructing this action. If someone could provide a script or a set of instructions on how to set this up, it would be of immense help.

Thank you all in advance for your time and expertise. Any help will be valued as I aim to make this a seamless part of my workflow.

1 Like

There is an Obsidian Integration guide here Using Obsidian with Drafts which should help get you started.

Probably also worth investigating Drafts Workspaces to gather your “news items”.

You want to start by configuring an action that will do what you want with a single draft. In this case, it would be writing that out to a file in your Obsidian Vault. The Obsidian guide has examples to get you setup there, and configure your bookmark, etc.

Regarding specifics of your configuration, if you keep your title on the first line it’s a bit easier. Drafts has template tags for [[title]] to extract the first line (with Markdown heading stripped) and [[safe_title]] for the first line as a file-name safe version. You would only also need to configure the Path value to direct the file to a specific subfolder.