Macro to add/populate note title in Evernote

A slight irritant with Evernote is that title and body are separate, and when inserting a note, one has to copy the title in the title field.
I would like to create a marco whereby I would highlight a line of text which would serve as the title of the note, then activate the macro and the title field would be populated with the highlighted text.
In Scrivener for example, the function is already integrated : highlight text, type of key combination and the text pops up as the document title.
thanks in advance for your help

I think you know how to create a Macro with an Execute AppleScript action, so just do that and use this script. It seems to work OK with the limited testing I have given it, but you should test with a TEST NOTE before using in production.

###How to Use

  1. Select some text in Evernote Mac that you want to be the Note Title.
  • Trigger this macro/script.
  • If nothing is selected, the script will abort without making any changes.

NOTICE: This macro/script is just an Example

  • It is provided only for educational purposes, and may not be suitable for any specific purpose.
  • It has had very limited testing.
  • You need to test further before using in a production environment.
  • It does not have extensive error checking/handling.
  • It may not be complete. It is provided as an example to show you one approach to solving a problem.

2017-07-07 18:38 CT -- VER 1.1

  • Added cleanup of selected text to remove:
    • Returns and Linefeeds
    • Leading and Trailing whitespace

Note this Requires Satimage.osax
(Free D/L & info at )

###AppleScript to Set EN Note Title to Selected Text

property ptyScriptName : "Set EN Note Title to Selected Text"
property ptyScriptVer : "1.1" -- ADD Clean up text
property ptyScriptDate : "2017-07-07"
property ptyScriptAuthor : "JMichaelTX"
property LF : linefeed

    1. macOS 10.11.6+
    2. Evernote 6.9.2+
    2. Satimage.osax (Free D/L & info at )

tell application "Evernote"
  set the clipboard to "[NOTHING]"
  delay 0.2
end tell

tell application "System Events"
  keystroke "c" using command down
  delay 0.2
  set newTitleStr to (the clipboard as text)
  --( requires Satimage.osax )
  --- Remove Return and NewLines ---
  set newTitleStr to change "[\\r\\n]" into " " in newTitleStr with regexp
  --- Remove Leading Whitespace ---
  set newTitleStr to change "^[ \\t]+" into "" in newTitleStr with regexp
  --- Remove Trailing Whitespace ---
  set newTitleStr to change "[ \\t]+$" into "" in newTitleStr with regexp
  tell application "Evernote"
    set noteList to selection
    set oNote to item 1 of noteList
    set oldTitleStr to title of oNote
    set msgTitleStr to "Replace EN Note Title with Selection"
    if ((newTitleStr ≠ "[NOTHING]") and (newTitleStr ≠ "")) then
      --- UPDATE NOTE TITLE ---
      set title of oNote to newTitleStr
      set msgStr to ¬
        "EN Note Title Changed:" & LF & "FROM:" & tab & oldTitleStr ¬
        & LF & "TO:" & tab & tab & newTitleStr
      display dialog msgStr ¬
        with title msgTitleStr ¬
        buttons {"OK"} ¬
        giving up after 4
      set msgStr to "Current Title:" & tab & oldTitleStr ¬
        & LF & ¬
        "No text was selected." & LF & "Script was aborted without making any changes."
      display dialog msgStr ¬
        with title msgTitleStr ¬
        buttons {"OK"} ¬
        default button ¬
        "OK" with icon stop
    end if
  end tell
end tell

1 Like

Thank you so much for your answer !
I apologize for the delay.
I was playing around and found one method using BTT and a trackpad
4 taps (=left mouse clicks) (it highlights the line on which the cursor is located in the body of the note) ➤ Copy ➤ Cmd-L (go to title field) ➤ Paste ➤ I then add a Date at the end of the title ➤ Tab (back to the body)

I would like to convert the MTT macro to a KBM macro.
I asked you a while back if there was a way to type left mouse clicks (or trackpad taps) with KBM. You gave me a very good answer using simple MAC shortcuts, but problematic because I use those shortcuts in KBM for something else).
If I may do so, I would like to ask you again: type left mouse clicks (or trackpad taps) with KBM ?

thanks very much

Sorry, nothing has changed since my last answer.

1 Like

Thank you. Funny: I was looking into a question in the Evernote forum, and people were referring to you as the expert.
The problem is how to do a search the NOTES in the CURRENT notebook you are working in. Alt-Cmd-F highlights the search window for all notes, and its necessary to click on the notebook name below the search box to restrict the search to the current noteboook. Would you by chance have adressed this in the past? It seems quite basic, ie searching for something in the current notebook you are working in. Starting to search by syntax, entering the notebook name is too cumbersome.
thanks again

Please post a new topic for this question, as it is a very different subject.

1 Like

yes, you are right. I will.