Hazel Rule to export new drafts to txt files

Anyone has made a Hazel rule that will export new drafts to a folder of choice as txt files?

I need to have Devonthink Pro 3 powerful index to search all my text files for research purposes, and love to use Drafts quick capture (rather dan Devonthink own clumsy Note taker), but I cannot point DevonThink 3 to the iCloud folder where Drafts are encoded, nor DT3 would understand that proprietary drafts format.

Thanks!

Hazel works on files, but Drafts’ drafts are held in a database, not in files. The only way you could have Hazel do something like this is if you were to periodically export any new drafts to a folder. At that point all the normal rules of Hazel would apply and you could use many of the import automations available for Devon Think at that point.

Fairly easy to do with a drafts action I think.

I have been looking at Actions in the directory and I have not seen one that can act on new drafts and export them as individual text files… yet.

I saw some actions to write to iA Writer, which handles md and txt files in its own iCloud drive folder (wish Drafts would do that!), but that is another intermediate step I wanted to avoid

You could select a set of drafts and batch run this action.

https://actions.getdrafts.com/a/1EW

Or this thread has a script you can put in an action where you can fill in a query to select which files to save to file.

1 Like

I use Hazel to move files created by Drafts in the Drafts folder within iCloud, to another apps folder—also in iCloud. It’s simple, and I hope it helps you achieve what you’re looking for. This is a link to the article I wrote about it.

The second rule I use is for appending text to a file that I want to show up outside of the Drafts folder. It uses transclusion, so I don’t know if it’ll be helpful outside of Obsidian.

Drafts is set up to create then append text to a note (YYYY-MM-DD - Captain’s Log) in the Drafts folder in iCloud. Hazel watches that folder and creates a copy of the file to the Obsidian folder (also in iCloud) every time it is modified. I have a daily note set up in Obsidian with a transclusion using the same name as the file Drafts created, so that file shows up as part of my daily note and can be added to by Drafts throughout the day.