Opening the enclosing folder of an Apple Note

Searched here and on Google, no luck. Seems like an obvious functionality so I’m sure I’m missing something simple.

Say I have a note in somewhere in Apple Notes, say “My Bank Account Info” in the folder Personal>Finance.

Now I do a search for my “account info” and sure enough the note pops up in the search results. In the left sidebar I see the note’s title, date, hit snippet and the enclosing folder name, in this example “Finance”.

All nice and good but now I want to go to that folder so I can look at other notes or, commonly, create another note in that folder. Seems like clicking on the folder name in the sidebar should do it, or right-clicking on the note should pop up an “Enclosing folder” option. But none of this works, and I haven’t found another way of quickly getting to that folder. In this example, I wouldn’t even know it’s a subfolder of Personal. This is a trivial example but I have a couple of hundred folders, and it’s not always easy to remember where something lives.

Any suggestions?

(In my google search, I came across this question a couple of times, with no answers. Or people mistakenly thought the poster was asking about finding the Finder folder for a note, but this is about finding and opening the enclosing folder in the Notes app itself).

2 Likes

Try this, which I got from here:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Notes"
	set noteID to «class seld» of (selection as record)
	set noteContainerID to «class seld» of ((container of note id noteID) as record)
	set selectedNoteName to name of note id noteID
	set folderName to name of folder id noteContainerID
	show folder folderName
end tell
1 Like

Thank you! It works — sorta. Sometimes running it takes me to the All iCloud folder. But running it a second time will then take me to the parent folder. At other times, it takes me straight to the parent folder. Haven’t figured out what triggers what behavior. In every case I have the note selected from the search results.

That’s dang weird. My testing was very limited (n=1) so I didn’t see this behavior before.

It seems to consistently open first the “iCloud collection” and when invoked a second time open the folder you want.

I’m no applescript expert so I pretty much stuck. I can speculate that the “iCloud collection” is the container of the search results list? Though it does seem to find and attempt to open the correct folder on the first invocation, so it’s something weird in Apple Land most likely.

Aha! workaround:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application "Notes"
	set noteID to «class seld» of (selection as record)
	set noteContainerID to «class seld» of ((container of note id noteID) as record)
	set selectedNoteName to name of note id noteID
	set folderName to name of folder id noteContainerID
	show folder folderName
	show folder folderName — see what I did here?
end tell

Thank you ! This helps a lot. I keep wondering where I have nested my notes :slight_smile:.

Also, can you explain why this line is needed? It does not appear to be used.

It works! Thank you. Now I need to find a way to quickly launch it. For now, I use the Script Menu in the menu bar.

I admit, I’ve never been a fan of AppleScript. Its obscure syntax is way to “chatty” for my taste.

You’re exactly right, it’s not needed but was part of the code I found via Google. I left it in because I was using it to try to fix the bug under discussion (i.e. open the folder by ID rather than name. Didn’t work, but I learned stuff.)

1 Like

re Applescript: Totally agree, and I’m trying to use JXA more. But sometimes the answers you Google are in Applescript.

re launching the script: Gotta plug Keyboard Maestro here, but you might take a look at Fastscripts as well. (I have the former so haven’t used the latter myself)

2 Likes