Jump to content

Recommended Posts

This just creates a new note in notes.app. To keep it simple, it just uses the first folder in the first account it finds. You can change this behaviour by editing providing the respective names in the "properties" in the applescript.

 

Usage

 

To search existing notes, type "n search_term" into Alfred. E.g. "n something I wrote yesterday" (not working in macOS High Sierra)

To create a new note, just type "n note_text" into Alfred. E.g. "n something very important I will probably forget"

To create a note from the clipboard, type "nclip optional_note_name"

Hold option to open the note in a new window after creating it.

 

ie1504.jpg

 

iCloud Notes on OS 10.11+

 

As of Mac OS El Capitan, you are given the option to upgrade iCloud notes accounts. Once you do this, with the normal Notes workflow you'll start seeing duplicate lines in notes. The reason for this is that prior to the upgrade the "Title" of the note and the "Body" of the note were displayed separately. After the upgrade, Notes assumes the title is *not* also included in the body, which is different behaviour, and led to the apparent duplication.

 

Sadly there's no reliable way for the workflow to detect whether your Notes account has been upgraded or not, so fixing it would entail breaking it on installs that have not undergone this upgrade. Therefore I have opted to make a separate Workflow which is to be used by anyone who has upgraded to the new iCloud version of Notes. You will find that download link below.

 

Changelog:

  • Tuesday, 5th July 2016 - Fixed a regression where "nclip" would not work if a custom title was provided

  • Thursday, 30 June 2016 – Compatibility for users who did not previously have Alfred v2 installed

  • Wednesday, 27 January 2016 – Fixed an issue with notes from clipboard not working; existing iCloud notes are now searched too (thanks, Vero!)

  • Friday, 16 October 2015 – Added a new Workflow for iCloud upgraded notes in OS 10.11+ (Thanks Nikita!)

  • Monday, 27 October 2014 – workaround for apple bug #18734006 on OS 10.10

  • Monday, 13 October 2014 – Hold option to open note window after creation

  • Tuesday, 17 September 2013 – Updated q_workflow module to latest version

  • Thursday, 18 April 2013 – Only first line is used as a title when using "nclip" with no arguments

  • Sunday, 7 April 2013 – Properly escape illegal characters in query

  • Friday, 5 April 2013 – Fixed an issue where a temporary file was getting written to the wrong place, sorry about that!
  • Thursday, 4 April 2013 – Combined into single workflow; renamed to "Notes"; fixed an issue with clip keyword; nclip now pastes HTML if possible; workflow will notify if updates are available
  • Saturday, 16 March 2013 – First version

 

Download (Alfred v3 and iCloud)
http://bit.ly/2w2mILX
 
Note: this workflow will notify you if a newer version is available. To disable this functionality, change the property "shouldCheckForUpdates" to "false"

 

Alfred v2

It's not currently known whether the latest release will be backward-compatible with Alfred v2.

If you are using Mac OS 10.11+ and have "upgraded" your iCloud notes, you should use this workflow:

Notes for Alfred v2 (iCloud)

 

In all other cases, this is the one to use:

Notes for Alfred v2 (non-iCloud)

 

Sourcehttps://github.com/surrealroad/alfred-notes

 

Issues

Please raise issues on GitHub, as it's easier for me to keep track of them there.

Edited by surrealroad
added issues note

Share this post


Link to post

Works like a charm! Thanks, "Surreal." This is perfect for creating a quick note, like when you're on the phone and someone wants to quickly give you a phone number or snippet of information that you'll want on all your iDevices. Thanks so much!

Edited by bocaboy

Share this post


Link to post

The latest version of this workflow will now notify you if there's a newer version available. I would strongly recommend everyone updates to this new version.

Share this post


Link to post

It seems a note with "&" prevents a note from being created -- text under search bar turns to "Fetching notes..." ("&" is present in some hyperlinks that I like to add to notes). Can you try to fix that? Maybe just happened with latest update since first time using notes since update and it happened (but could also be just first time I used an "&").

Thanks!

Share this post


Link to post

It seems a note with "&" prevents a note from being created -- text under search bar turns to "Fetching notes..." ("&" is present in some hyperlinks that I like to add to notes). Can you try to fix that? Maybe just happened with latest update since first time using notes since update and it happened (but could also be just first time I used an "&").

Thanks!

 

Fixed. See the latest version.

Share this post


Link to post

Hi Jack How are you doing the Check for Updates I haven't seen anyone else have a system to check yet I hope Alfred gets a official workflow update system soon we have needed one since V1 

Share this post


Link to post

Hi Jack How are you doing the Check for Updates I haven't seen anyone else have a system to check yet I hope Alfred gets a official workflow update system soon we have needed one since V1 

 

You can dig around with the code if you like, it runs "cache-update.scpt" in the workflow folder with the bundle id as a parameter.

 

But basically it pings a webpage (once every 4 days by default) with the bundle id, which replies with the latest version. If a new version is available, I simply add an action to alfred to download it.

 

My implementation is a little more complex than that, mostly because I have a shared codebase between all my workflows.

Edited by Jack James

Share this post


Link to post

The only problem Jack is only one of the workflows I use has had this added out of 38. Im gonna visit the site of each of the workflows I have installed to check for updates manually today and hope some have added support.

Share this post


Link to post

Hi, this is maybe stupid question, but how to search notes from Alfred? I'm not able to figure it out.

That's not possible, at least not with this workflow. I thought about adding this feature, but the problem is there would be now way to actually "open" a specific note in the notes app, which would be really lame.

Share this post


Link to post

That's not possible, at least not with this workflow. I thought about adding this feature, but the problem is there would be now way to actually "open" a specific note in the notes app, which would be really lame.

 

And is the a way, to add Notes to Features > Default Results? In other words, how do you search notes from Alfred? :) Spotlight does it, so it should be possible :)

Share this post


Link to post

I believe spotlight "cheats" in some way to do this. If you try your spotlight search in a finder window rather than the spotlight icon on the menubar, you'll see it doesn't actually find any notes.

 

I *can* make the workflow show your notes in alfred, but as I said, it would be kind of pointless because you can't make them actually open up.

Share this post


Link to post

Hi guys, you can actually open a note in Notes.app when you search for it with Alfred, it looks like this:


 


Bildschirmfoto%202013-04-26%20um%2018.08


 


@valon, a search filter might be what you're looking for. I made one for notes and it works really well! Just connect a "File Filter" module to an "Open File" module like this:


 


Bildschirmfoto%202013-04-26%20um%2018.31


 


In the file filter you have to set the search scope to:


/Users/Your Username/Library/Containers/com.apple.Notes/Data/Library/CoreData/ExternalRecords/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/IMAPNote/_records/0/


... the "XXX" represents a string of letters and numbers; 


 


Then just drag one of the notes into the "File Types" field (the file type is called "com.apple.notes.externalrecord"). Now give the search filter a keyword and you can search for your notes. If you press enter, Notes.app will open up the note in a separate window (like in the picture above).

Share this post


Link to post

Hi guys, you can actually open a note in Notes.app when you search for it with Alfred, it looks like this:

 

 

 

@valon, a search filter might be what you're looking for. I made one for notes and it works really well! Just connect a "File Filter" module to an "Open File" module like this:

 

 

 

In the file filter you have to set the search scope to:

/Users/Your Username/Library/Containers/com.apple.Notes/Data/Library/CoreData/ExternalRecords/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/IMAPNote/_records/0/

... the "XXX" represents a string of letters and numbers; 

 

Then just drag one of the notes into the "File Types" field (the file type is called "com.apple.notes.externalrecord"). Now give the search filter a keyword and you can search for your notes. If you press enter, Notes.app will open up the note in a separate window (like in the picture above).

 

Excellen, this is what I was looking for :) I was not able to locate note file. I've added this file type to Default Result and added location do search scope and it works great :)

Share this post


Link to post

Jack James, 

 

Thank you for sharing your work flow.

 

I do have a question, though: Would it be possible to open Notes.app and focus on the newly created note? It seems picky, but it would greatly streamline the creation process for me. My conceptualization of the process would be to "simply" open the newest '.notesexternalrecord' file in the notes folder, but I have no idea where to start with this modification. Any help would be much appreciated.

Share this post


Link to post

That's an interesting approach. You can probably just append to the workflow a call to system events to find the most recent file in a given folder, and then just use the open command to launch it. That said, I have no idea whether this would even work _outside_ of this workflow.

Share this post


Link to post
Thank you for the pointers. I modified the end of the 'run script' to reflect the following:
else
lib's createNote(first paragraph of q, q, notesFolder, notesAccount)
set theResult to "Created note: " & q
tell application "Finder"
   open (every item of folder "Macintosh HD:Users:USERNAME:Library:Containers:com.apple.Notes:Data:Library:CoreData:ExternalRecords:XXXX-XXXX-XXXXX-XXXXX:IMAPNote:_records:0" whose modification date is ((get current date))) 
end tell
end if
return theResult
end alfred_script

It seems to work as intended. My only remaining curiosities are "is this inefficient (best practice)" and "can I place/focus new text input at the end of the now-filled 'query' text"?

Edited by foxtrot

Share this post


Link to post

Very interesting!

So the thing to do would be to modify the alfred_library.scpt in the bundle:

on createNote(noteTitle, noteBody, notesFolder, notesAccount)
	tell application "Notes"
		if notesAccount is not "" then
			tell account notesAccount
				if notesFolder is not "" then
					tell folder notesFolder to set theNote to make new note with properties {name:noteTitle, body:noteBody}
				else
					tell first folder to set theNote to make new note with properties {name:noteTitle, body:noteBody}
				end if
			end tell
		else
			tell first account
				if notesFolder is not "" then
					tell folder notesFolder to set theNote to make new note with properties {name:noteTitle, body:noteBody}
				else
					tell first folder to set theNote to make new note with properties {name:noteTitle, body:noteBody}
				end if
			end tell
		end if
	end tell
	--this is the bit that will open the note
	set old_delim to applescript's text item delimiters 
	set applescript's text item delimiters to "/"
	set noteFile to (last text item of theNote's id) & ".notesexternalrecord"
	set applescript's text item delimiters to old_delim
	do shell script "find ~/Library/Containers/com.apple.Notes/Data/Library/CoreData/ -name " & quoted form of noteFile & " |xargs open"
end createNote

I'm actually considering putting this into the released workflow, maybe via a modifier key. Very cool!

Edited by Jack James

Share this post


Link to post

Found editable alfred_library.scpt on GitHub (the reminders workflow), implemented above suggested changes, (again) encountered errors. Google search indicated the errors were likely Mavericks related: 'as text' is apparently now required. Working changes included below. Thank you again for your help!

--this is the bit that will open the note
	set old_delim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to "/"
	set noteFile to (last text item of (theNote's id as text)) & ".notesexternalrecord"
	set AppleScript's text item delimiters to old_delim
	do shell script "find ~/Library/Containers/com.apple.Notes/Data/Library/CoreData/ -name " & quoted form of noteFile & " |xargs open"
Edited by foxtrot

Share this post


Link to post

I've updated the main workflow with this change– you can now hold down option in Alfred to open the note in a Window, and there's a property in the "Run Script" action (alwaysShow) which will always do this if set to true.

Share this post


Link to post

'n anything' just displays the web search for me. It flashes the 'Add note' as an action briefly but quickly dissapears replaced with other search results. Any pointers how to rectify?

Share this post


Link to post

'n anything' just displays the web search for me. It flashes the 'Add note' as an action briefly but quickly dissapears replaced with other search results. Any pointers how to rectify?

Can you try the command again, with the extension visible and debug on (click the bug icon in the top right of the workflow window). Then paste the results here.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×