Create, use then delete duplicate draft

I have Taskpaper list which I sometimes want to convert to a markdown to-do list and send to Obsidian.

I have an action which creates a duplicate of the draft, strips the tags, converts the Taskpaper “-” to markdown “- ” and sends the duplicate to Obsidian. So far so good.

Once this is done I want to delete the duplicate draft and if I use “after success” to move it to trash it is the original that goes to trash and not the duplicate. Please advise how I can trash the duplicate and keep the original.



Either modify the action to address the created draft rather than the current draft by setting the istrashed true or modify the action to not create a new draft at all and just manipulate and share a copy of the original content (without placing it in a new draft).

1 Like

Thank you @sylumer - I’ll try the ‘istrashed’.

@sylumer Thank you - working now and it is just what I wanted.


You may have a reason for creating the draft, but you might just want to just adjust the content and send it off without generating a duplicate. That might be as easy as not calling update() on the draft you create in your example.

1 Like

Thank you @agiletortoise that seems like such an elegant solution and it may be but I can’t get it to work. I had another look at what I believed to have worked before and realised it wasn’t working. The conversion happens but the action sends the original draft to Obsidian - I am unable to distinguish between my original and the copy after the conversion.
Now, I can do it but in two steps. First, convert the Taskpaper draft to a markdown checklist without any tags. Then send that to Obsidian and delete on success.

Could you share your action? Happy to help, but need to see what’s going on.

I use this script as the stage before your “Send to Obsidian Vault” action

var d2 = Draft.create();
d2.content = draft.content;
d2.languageGrammar = draft.languageGrammar;

for (let tag of draft.tags) {

const findRegex = /^(\s*)\- /gm;

// define replacement expression…
const replaceWith = "$1- [ ] ";

// do the replacement…
draft.content = draft.content.replace(findRegex, replaceWith);

Now I have two versions of the Draft, one Taskpaper which I want to keep and the other a tag-free markdown version which I want to send to Obsidian and then delete.

The “Send to Obsidian Vault” action ignores (probably correctly) my reformatted duplicate and sends the original to Obsidian.

Finally, I would like to delete the duplicate after sending it to Obsidian.

I appreciate your help, thank you.


I would suggest simplifying that by never creating another draft you don’t need.

This just creates a variable s containing the Markdown version you want to send…

const findRegex = /^(\s*)\- /gm
const replaceWith = "$1- [ ] "

// put markdown version in a variable
let s = draft.content.replace(findRegex, replaceWith)

It sounds like you are trying to combine this with the “Send to Obsidian Vault” action, which uses a URL to open Obsidian.

You could continue this script to create a template tag with the newly generated content, like:

draft.setTemplateTag("markdown", s)

Then, in the Open URL step (which has to happen after the script step), just change the [[content]] tag in the URL to [[markdown]] to use this generated text instead:


To summarize, you generate the new text, put it in a custom template tag, and use that tag in the URL template to output the markdown instead of the content of the draft.

1 Like

@agiletortoise Thank you so much. Works perfectly. I also removed the [[hashtags]] from the content Template Tag because Obsidian can’t handle scoped tags.

1 Like