Here’s my project: I want to build a library of plain text files where I will capture various items that I come across in my research or general reading. For example, I may find a section of a book or blog post about a topic of interest and then want to capture that in a way that’s quick and easy and that I can find again later.
The solution I want to build uses Drafts in iOS and macOS, and Hazel.
What I want to do is capture the text in Drafts with a tag that places that text into a workspace. I then want Hazel to find those files and place them into one of a number of folders depending on key words.
But at the moment I can’t figure out how to do that. It seems to me that the drafts files are not in a folder that I can find and so I can’t tell Hazel to look at that folder. Also when I expect as plain text the tags are not part of that text.
So… am I on the wrong path here or is there a way to make this work?
Drafts uses a database for drafts, not files. To work with Hazel, you would have to export each draft to a file. You could maybe automate some of that, but I think you should go back to what you want, what it will achieve for you (i.e. why you want it), and then back to what your capture and storage options are.
As said above, drafts runs on a database not folders. Why not come up with a drafts action that a) tags the note b) exports it to Dropbox or ICloud. Then your hazel rule could act on it to sort to a folder. Alternatively, shift to another program like NValt that will run from folders.
I wonder if there’s a way to automate searching the database using AppleScript to create the files I want.
I’m reluctant to change my capture method because I primarily capture on the iPhone and Drafts is my place to capture stuff. That said, I could have an action that creates a file, as aroddick suggests.
Is there any way to automatically run an action when a certain tag is present or on every file that has been updated since the last time the action was run?
You can tag the draft, but it might be better to set it as archive or do both. Archive is there for when you have finished processing. A tag would help if you need to identify drafts that have been processed in a particular way.
My question would be at that point, what is the benefit you are expecting from exporting it rather than simply using it within Drafts? There are pros and cons either way, but that’s why I suggested previously, going back to examining what it is fundamentally you are looking to get from this in terms of how you want to use it.
Note also, for parity you would need Drafts on Mac to support actions to fully go macOS capable for the action based export approach that would be employed on i*OS.
No, there isn’t currently a way to do this natively in Drafts. However, if you desperately wanted to do this, I’m 99% sure that a way could be devised using a Mac running 24x7, Keyboard Maestro (for scheduling and unattended key/click interaction), the current version of Drafts and the inbuilt, non-action based, export functionality.
The reason I want to export rather than just keep the stuff in Drafts is that these items will become part of a database at some point alongside other file types like images, PDFs, and audio/video files. These files would all be in a shared location used by my business partner as well.
My main reason for wanting to employ Hazel in this task is to avoid having to think about where items go. To that end a set of rules that read the content of a file and then simply place that file in the appropriate folder/folders is the main requirement. Creating the file itself is something I can easily do manually and it would be a good time to set aside a moment to consider which tags should be attached in the text in order to send the file to the right places.
I’ve found an action that takes tags and makes them into hashtags in the body of a note but for some reason that isn’t working. Maybe due to me being on a beta. Also there’s an action made by the developer to take items with a tag and place them in a folder as text files based on that tag.
So for the time being my plan is to use some basic hashtags and use that action to file items in a “database” folder. Then I run a hazel action to sort the files in that folder based on content (if it has the hashtag #datapoint place in the data folder.
Okay. The file system based hosting of your notes is key. The utilisation of Drafts is perhaps personal preference, but given you are willing to go a bit more manual than fully automated certainly makes a big difference in how workable this is.
You note the action you are using isn’t working. I’m on the beta, so if you share the details for the action, I can take a look; but I’m not currently aware of anything in the beta that would affect an action iterating through the tags and writing them back as hash tags into the draft or an export.
The way I resolve this is that I also flag all active notes. (And I use hashtags in the note, using a drafts action to convert to tags). Then I have a workspace in drafts that pulls in all tagged & flagged notes. I send them all over in bulk. Once processed, I drop the flag. If I change the note again, I flag it again. (In my case, all my notes are sent over to Devonthink via an action…but a copy remain in drafts).
It’s generally easier to share an action using the Drafts directory. You can make it unlisted.
The action works for me on the latest beta. It adds appends the tags as hash tags at the end of the tag.
The differences to mine is it stripes spaces in tags that have them (that’s an addition of a l replace in the loop in mine if preferred), and it updates the content of the draft; mine only passes it to the export.
Sorry, I don’t follow as to why it wouldn’t work on multiple drafts for you. I just tried it and it worked fine for me.i selected multiple drafts, then to run an action operation, selected the action, and it ran for each selected draft.
Absolutely. It was only intended to demonstrate a technique with the broadest possible file based output at the end. Switch out the final action for whatever your preference might be, but take note of the template tags being used in the existing final step.
The action then prompts me once for each draft to save it as a file. I chose to save each of them in my Temp folder in iCloud. This is the step I would change so as to involve no interaction if I had a common export location identified.
From this particular test I see the action as working. If the above doesn’t immediately flag up anything odd about how yours is running, please try and share the full details of exactly what you are doing in your test.
If you could post a screenshot of what you mean by “the sheet on the right” and perhaps a step by step description of what you did, I, or someone else on the forum, might be able to explain why it worked differently.