Share this post

Link to post

Thanks for putting this together! I came across a bug in getting this to work, and in fixing it wound up making some modifications ...

Mainly I figured out how to extract the note contents from the sqlite db and add them to the JSON match field. The contents are gzipped in the db so I had to decompress and clean them up in order to use them for search matching ... I imagine performance could be a concern if you have a gajillion notes, but it runs very fast for me, pulling about 1000 notes down at a time.

Modified python file contents are below - I made some other changes that may or may not interest you, but I can do a PR if you like.

Share this post

Link to post

Thanks for your contribution, this is great! @Jasondm007 was requesting this feature. Seems like people are into the full text search so we could make that the default and "search titles only" as an option.

I'm on vacation for a week but will add this when I'm back. You can make a PR if you want and/or I'll make a list of contributors on the github page.

Share this post

Link to post

Updated the workflow with some better AppleScript methods, including one that searches note bodies. @deanishe the JSON is being output properly now using Foundation framework methods. Note bodies are obtained from AppleScript in HTML which I parse using regex (against all internet advice, but has been working so far—notes with HTML snippets are going to be less searchable). Let me know if there are better ways to grab the body text.

I tried using JXA but found it was slower for me than AppleScript where I'm careful to access large objects as references.

I looked into the new note fallback option but this seems difficult for script filters in Alfred, especially when Alfred handles narrowing the search results.

Share this post

Link to post

Share this post

Link to post

@sballin Thanks for sharing this workflow. It's great, and has saved me a ton of time.

Out of curiosity, are there any small changes that could be made to your script filter so that it only searches for folders (i.e., as a new script filter based on the NS workflow)? Or, alternatively, is it possible to see folders in the results of the standard search (i.e., alongside/within the standard results for the individual notes)?

Share this post

Link to post

Thanks @sballin!! I almost gave up on Notes before this workflow! This thing is a life saver.

Sorry if I wasn't clear in my previous post. I meant to ask whether the folders, themselves, could show up as individual results (i.e., (1) among the individual note results or (2) by themselves, if an argument was added to the main script filter)?

I ask because there are times when I want to open a folder without knowing which specific note that I might have placed the material in that I'm looking for (i.e., in cases where I don't have a good enough idea of what I'm even looking for). I'd also like to be able to use it as a fallback search for times when the usual workflow isn't returning the note that I am looking for, but I know the folder where it's located. In short, I'm just looking for an easy way to search for, and open, folders.

Share this post

Link to post

Gotcha. I'm hesitant to mix folders and notes in the same search results, which is why I implemented the folder-only search you suggested. You can download the latest version of the workflow to try it.

I'm also fairly sure the "fallback" behavior you're describing is currently implemented. If I have a folder named Aardvark containing notes Bob and Charlie, when I do the normal "n" search for Aardvark, the results will be Bob and Charlie.

Share this post

Link to post

@sballin I don't mean to hijack this thread, but I have a Notes-related question that I was hoping to bounce off you that is somewhat related to your workflow:

Namely, do you know how to create local file link for a specific note in the Notes app (i.e., one that could be inserted - like any other file link - into any text editor)?

Since your workflow searches for, and opens specific notes, I thought you might know the answer.

While I understand that I can generate a link for a note by using the Share option in the Notes app, I don't want to actually share the notes with other people. Instead, I'd just like to insert links in other notes and other local text editors that I could click to open within the Notes app (i.e., using the standard Add link... option). In short, I was hoping to create links that would operate like Finder (file:///path...) or Evernote's so-called "Classic Note Link" (evernote:///view/path...), but I have no idea how the Notes app stores its notes.

Ideally, I was hoping to create workflow that would copy a specific note's link/path to the clipboard based on either:

the note that is in the Notes app's frontmost window, OR

as an alternative action from your workflow's search results (e.g., using ⌥+↩︎ to copy, to the clipboard, the link of a note selected from your workflow's search results).

I suspect both options are incredibly difficult ... so please feel free to ignore this message. In any event, thanks for any help you can lend!!

Share this post

Link to post

@Jasondm007 Nice idea, I've added this feature in version 1.4. Let me know if it works for you. If it asks you to choose a program to open the notes:// links, you probably need to move [workflow directory]/Note Opener/Note Opener.app to /Applications.

Share this post

Link to post

@Jasondm007 Nice idea, I've added this feature in version 1.4. Let me know if it works for you. If it asks you to choose a program to open the notes:// links, you probably need to move [workflow directory]/Note Opener/Note Opener.app to /Applications.﻿

I was able to get it working just by opening the app in its current location inside of the workflow (and approving the permissions - re: unidentified developer).