Jump to content
peeeeeeek

Finding built in Notes.app notes

Recommended Posts

When using Spotlight I can easily find any of my notes held in the Notes.app.

How do I find these using Alfred?

Eg. if I have a note titled "V6 Changes", when I type "V6" then Spotlight shows that note and I can hit return and the note is shown, can Alfred show it too just by typing "V6"?

 

Thanks,

 

Neil

Share this post


Link to post

Notes from the Notes.app are stored in a file:

 

~/Library/Containers/com.apple.Notes/Data/Library/Notes/NotesV2.storedata

 

This file is cannot be read easily with just TextEdit and requires Developer Tools to be installed if you are using a terminal command to load them into TextEdit with:

 

cd ~/Library/Containers/com.apple.Notes/Data/Library/Notes; strings NotesV1.storedata | grep body | open -f

 

Perhaps this could be moved to the feature request forum to add this natively to Alfred?

Share this post


Link to post

Notes from the Notes.app are stored in a file:

 

~/Library/Containers/com.apple.Notes/Data/Library/Notes/NotesV2.storedata

 

This file is cannot be read easily with just TextEdit and requires Developer Tools to be installed if you are using a terminal command to load them into TextEdit with:

 

cd ~/Library/Containers/com.apple.Notes/Data/Library/Notes; strings NotesV1.storedata | grep body | open -f

 

Perhaps this could be moved to the feature request forum to add this natively to Alfred?

This data can be easily read with a simple SQLite database app.

Share this post


Link to post

This data can be easily read with a simple SQLite database app.

SIMPLE? Hehe, perhaps a little more detail for those of us who have NO idea where to even begin on that Dave? please.

Share this post


Link to post

I get the impression Alfred doesn't just allow me to locate a note like Spotlight does.

Any solution would have to be easier than just using Spotlight!

 

Thanks anyway for the responses.

Share this post


Link to post

I get the impression Alfred doesn't just allow me to locate a note like Spotlight does.

Any solution would have to be easier than just using Spotlight!

 

Thanks anyway for the responses.

 

If you add (from your home folder) ~/Library/Containers/com.apple.Notes to Alfred's default search scope (Features > Default Result preferences), then Alfred will find the notes when you do a file search in Alfred (e.g. open keyword, or prefixing a search with spacebar).

Share this post


Link to post

If you add (from your home folder) ~/Library/Containers/com.apple.Notes to Alfred's default search scope (Features > Default Result preferences), then Alfred will find the notes when you do a file search in Alfred (e.g. open keyword, or prefixing a search with spacebar).

Thank you so much for this Andrew!

Share this post


Link to post

If you add (from your home folder) ~/Library/Containers/com.apple.Notes to Alfred's default search scope (Features > Default Result preferences), then Alfred will find the notes when you do a file search in Alfred (e.g. open keyword, or prefixing a search with spacebar).

 

Thanks Andrew, that works great.

Share this post


Link to post

SIMPLE? Hehe, perhaps a little more detail for those of us who have NO idea where to even begin on that Dave? please.

 

Yes, simple :)

sqlite3 "~/Library/Containers/com.apple.Notes/Data/Library/Notes/NotesV2.storedata" "select ZNOTE.ZTITLE, ZNOTEBODY.ZHTMLSTRING from ZNOTE join ZNOTEBODY on ZNOTEBODY.ZNOTE = ZNOTE.Z_PK"

That at the command line will query all note titles and their body and show them in the terminal. They will be shown per row with the title and the body separated by a pipe | character. That separator can be changed using the sqlite3 command. Since these records can be grabbed, all you need is a little script filter that will query based on the input, parse what it gives back and send that back to Alfred as XML. Simple! hehe

 

The down side is though that since recent changes to the Notes.app to be able to store images and other things as well, the body of the note is actually html. I'm sure other languages have it as well but php has a "strip_tags" function that will quickly strip the html out only leaving the note body. Also, not sure right off how to make the Notes app open directly to a note since we are referencing a record in an sqlite database. There may or may not be a way, im not sure.

Share this post


Link to post

... Although, this way only seems to find the notes by title, not by the contents which Spotlight does OK.

 

Instead of 'open', try the 'in' keyword to search inside files (and therefore, notes).

 

You could also setup a simple file filter workflow for just note types which looks at filenames and inside them too. I've quickly thrown together this workflow to get you started, with keyword 'note':

 

https://dl.dropboxusercontent.com/u/6749767/Alfred/Workflows/Search%20for%20Notes.alfredworkflow

Share this post


Link to post

Instead of 'open', try the 'in' keyword to search inside files (and therefore, notes).

 

You could also setup a simple file filter workflow for just note types which looks at filenames and inside them too. I've quickly thrown together this workflow to get you started, with keyword 'note':

 

https://dl.dropboxusercontent.com/u/6749767/Alfred/Workflows/Search%20for%20Notes.alfredworkflow

 

Thanks Andrew that works a treat, exactly what I'm after.

Share this post


Link to post

If you add (from your home folder) ~/Library/Containers/com.apple.Notes to Alfred's default search scope (Features > Default Result preferences), then Alfred will find the notes when you do a file search in Alfred (e.g. open keyword, or prefixing a search with spacebar).

How do I add this path?  When I go to that pane and click the + sign to add to the Search Scope, the Library folder is hidden so I cannot add it?

 

Thanks,

Share this post


Link to post

How do I add this path?  When I go to that pane and click the + sign to add to the Search Scope, the Library folder is hidden so I cannot add it?

 

Thanks,

 

If you use cmd+shift+. this will show hidden files in OS X's "Open" sheet... this is a neat little trick which works in all OS X sheets :)

Share this post


Link to post

I remember now there is a keyboard command that shows hidden files, but that is not working for me.  I already have hidden files showing in my Finder as I must have made a change in terminal a long time ago making them show, and in my OSX Finder I see the Library folder showing inside my User name, but when I click the plus button for Default Results>Search Scope, none of the hidden files show as they do in my finder. And if while looking at the finder options in that pane, if I hold down the Shift and Command key, that does not make them show.  Am I doing something wrong?  I am running OSX 10.10.2.

 

thanks,

Share this post


Link to post

I remember now there is a keyboard command that shows hidden files, but that is not working for me.  I already have hidden files showing in my Finder as I must have made a change in terminal a long time ago making them show, and in my OSX Finder I see the Library folder showing inside my User name, but when I click the plus button for Default Results>Search Scope, none of the hidden files show as they do in my finder. And if while looking at the finder options in that pane, if I hold down the Shift and Command key, that does not make them show.  Am I doing something wrong?  I am running OSX 10.10.2.

 

thanks,

 

You need to press shift+cmd+. (shift command dot), not just hold down shift and command... this will toggle on and off the hidden files.

Share this post


Link to post

Does Alfred know something special about that Notes folder, or does it just read any sqlite databases in the path? I ask cos I tried to add ~/Library/Safari in the hope that it would include my Safari History in the default search results but no success. I guess I should open a new topic for the real question...

 

http://www.alfredforum.com/topic/8796-how-do-i-add-safari-history-to-default-search-results/

Edited by smagdali

Share this post


Link to post

Hi @Andrew - Thanks for posting your Notes file filter workflow. It looks like some version of it has been incorporated by several others. I love the filter, and use it several times a day!!

 

Is it possible to modify the workflow, so that it searches for iCloud folder names in the Notes.app, and then opens the app to the first note in that folder (i.e., as a separate workflow or added to the present one)?

 

Apologies for cross-posting, as I posted a similar question in a different workflow thread; I didn't realize that you were the creator of this aspect of that workflow.

 

Thanks for any help you can lend!

Edited by Jasondm007

Share this post


Link to post

@Jasondm007 the workflow I created was a simple file filter (using macOS metadata). Modifying this to look for specifics within Notes.app (such as note folders) would be rather more involving, and I suspect, a bit more scripting. Somebody here may be able to prove me wrong on that though!

Share this post


Link to post

@Andrew Thanks for getting back to me so quickly!

 

Yeah, I was hoping there was a metadata tag for folders in the Notes.app that would be easily added to your filter. Hopefully, others will have some ideas.

 

While I'm new to scripting (and Alfred), it's odd that there's not much documentation available from Apple or other developers on the Notes app. Unfortunately, it doesn't look there's an easy way to even open notes via applescript. It's easy enough to identify the relevant note to open, but I can't figure out how to actually open it.

 

For example, the two scripts below can retrieve the name of the first note in the folder "FOLDERNAME" or its x-coredata:

 

Name

Quote

 

tell application "Notes"

    activate

    get name of the first note in folder "FOLDERNAME"

end tell

 

 

 

X-Coredata

Quote

 

tell application "Notes"

    activate

    get first note in folder "FOLDERNAME"

end tell

 

 

 

The x-coredata makes it easy enough to manually find the note in Finder. Opening it, however, is a little beyond my limited skill set.

 

Does anybody else have any ideas? Thanks in advance for any help you can lend!!

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...