How to Build KM Macro to Select & Apply Evernote Tags

Amazing job @DanThomas,

I was planning to use you solution to help me adding tags to Evernote but I’m facing a problem you might help me with.
When I run you script with my data it loses the focus on evernote search field dialog so I’m not able to input the value directly from you script. Same thing happens when, for instance, trying to create a new tag. Evernote cancels the edit. I hope I’m explaining myself correctly.
I do understand that this is the way you wrote the script, the way you deal with the screen, etc.
What I’m trying to do is that in Evernote, whenever I’m searching for tag or adding new ones, I palette would appear allowing me to select the right one BUT, instead of a huge list of tags what I’m looking for is a way to start typing a few letters so I can filter and choose the one I need. In the same way you search for text values in your script but without a popup window. Kinda like a textexpander + search inline… make sense?
Any ideas. Thanks for your help in advance.

@JMichaelTX - Jim, as a fellow Evernote user, perhaps you could help interpret @turko’s post (above)?


I’m a big Evernote and KM user, and I like your idea. In fact, I’ve thought of doing a similar thing using @DanThomas’ “Spotlight Search Prompt”.

It would be best if you can post/upload the Macro you have so far.
But my initial thoughts are that you would need to use KM to select the Evernote Tag(s) that you want, and then have KM paste (or type) the properly formatted result into the proper field in Evernote.

I have a KM Macro that does something very similar. It allows the user to select text (from anywhere), or enter text, that will be used as a “intitle:” search in the Evernote Search block. The Macro selects/clears the Evernote Search field, and then pastes something like this:

inline:"users search text"

In your case you would use KM to build the proper search string for tags, something ilke this:

tag:myTag1 tag:myTag2

I would love to see how you are getting your tag list from Evernote, and then using that with @DanThomas’ macro.

Perhaps together we can build a great KM macro for Evernote.

1 Like

Well, so far, so good, I guess.

This is what I’ve done so far:

  • Applescript to export all EN tags (i.e: bills, whitepapers, reports, taxes, etc)
  • Excel to recreate tag hierarchy since EN has no way to maintain such a taxonomy for tags (except) for presenting purposes. No filtering, etc. This way I end up having this taxonomy:

so on…
This is the only way to actually filter and apply logical operators to make some sense of the actual EN implementation.
Since EN does not allow to structure the way you asign tags to notes (amazingly IMHO) (Windows client does BTW) you end up having tons of unused tag everywhere without a logical structure. At least in my case.
So I decided to build a system that provides me that logical structure I needed not only for new tags but for later processing.
I have used a mindmapping software to do the categorization and then export to csv file for later processing (200+ tags) Now I have 3 main categories and a dozen branches…

  • Using @DanThomas macro I’ve dumped all these entries in the macro because it helps me find the tag I want instantly but since I use that naming convention I do not miss the logical structure.

Now the problem is in EN combined with the macro. If you hit command+f to do a search in EN and run the macro, EN cancels the entry box. So the macro would not return the value to the EN search field. Same thing happens somewhere else like creating a new macro. This issue cancel the hole purpose of my idea until I found a very stupid solution: place a “insert text” action just before running the macro. This way EN does not cancel the entry box. You have to use the mouse to move focus to the macro dialog again but I can take it.
Unless you see a better approach.
End of story, I have a tagging system working and I hope one day I could forget this stupid naming convention EN made us use. It only took me this hole day to find a suitable solution.

I hope I made myself clear. I do not write much in English.

Actually Evernote can maintain a tag hierarchy which can be preserved when using an export of tags using AppleScript. The tag object has two properties:

  • name
  • parent

However, the AppleScript export does not produce a hierarchical list.
Perhaps that is what you are using Excel to do?

Can you please share the details of how you do this?
It would be great if you could post/upload the macro/scripts needed to setup/use Dan's macro.

You need to run the KM Macro first to select and build the Search string.
Then, the Macro should activate Evernote, select and clear the Search box, and the paste the formatted search screen with your selected tags.

Here is a part of my macro which pastes a search string into the Evernote Search box:

I know but tags are unique and EN does not take into account the hierarchy for anything except representation on the client. You can not search & filter by parents, etc. and when assigning a tag to a new note you not only has access to the hierarchy buy there is not even an autocomplete available.

I used excel to build the naming convention concatenating the tags to produce the fictional hierarchy and then pasting it in the macro as this:

It wont work becase it will make imposible to concatenate searches, etc. Besides when making & renaming new tags will not work. I was looking for a better approach. Now it's working just by adding (as I said before) this little trick:

just a little space so EN does not close the search dialog.
And this is the results:

As I said, I hate this naming convention but it's EN's lack of tag hierarchy that forces this approach.


Thanks for sharing these details.

I have just uploaded my EN Search macro:
MACRO: @EN Search Title of All Evernote Notes

Would you mind uploading your macro?

@DanThomas,  some questions about your [MACRO: Spotlight Search Prompt](

1. I have about 1,500 Evernote Tags.  Do you think your macro can handle this number without any performance/delay issues when the user is typing text to filter the list?  
2. Each EN Tag also has a Parent tag.  Is there an easy way I can first filter on Parent tag, then on the child tag?

Just to clarify, when I said that autocomplete was not available I was talking about EN presenting an hierarchy of tags to choose from. EN remembers tags previously used but it will not populate tags based on the hierarchy you define in the tag viewer. So you can’t type a root tag an expect EN populate children tags…

The good thing about using this naming convention is that you have spotlight by your side again. Now it's super easy to find stuff.

No idea - never tried it. I’m curious to see, though. If you can generate the list easily, you can run a test pretty quickly. Let me know!

Each EN Tag also has a Parent tag. Is there an easy way I can first filter on Parent tag, then on the child tag?

The only thing I can think of is to prefix the parent tags with something, so they’re different than any children.

Thanks for sharing that.

I have used the Mac Spotlight to search for my EN Notes, but it never occured to me to search for EN Tag names. I use a similar tag naming convention to yours, and it found my EN Notes immeditely.

Some examples of my Evernote Tag Name:

  • SW.KM
  • SW.AppleScript
  • FU.Action

Evernote does provide a cool drop-down list of tags when you use the Tag Filter:

As you can see, I have a lot of "SW" (Software) tags, probably too many . . . :wink:

If only the Evernote Search block would work like this when I type "tag:", it would be awesome.