Jump to content
2019 Calendar Templates Read more... ×

Recommended Posts

Instead of hijacking other discussions, I am using this discussion to discuss general scripting on a Mac

5aabe5fad2569_ScreenShot2018-03-16at08_41_01.png.afceefd741509c8e191f29cd6c41f1f8.png

Evernote/Mac has a scripting layer built in to the app.  
This feature is accessed using AppleScript with the app Script Editor.

 

There's documentation at https://dev.evernote.com/doc/articles/applescript.php

and the Script Editor displays a dictionary for each app5aabe7bdc6837_ScreenShot2018-03-16at08_48_58.png.60683c848be872fe1bdff563e4ad7c95.png

 

Table of Contents

  1. Storage and Menu for accessing scripts
  2. Script: Identify the Note OD File Folder
  • Like 1

Share this post


Link to post

Two points about the storage and access of Applescripts.5aab78258ccd5_ScreenShot2018-03-16at00_49_45.thumb.png.10509ddb69ff81b4f1c00638cb209b0f.png.a905a79d06a4547e34494e8cbae34573.png.0472805c3f3cae1f81e8619ef13f184a.png

I show a menu of scripts in my top menu bar.

  1. I store the Evernote scripts in folder /Users/<user>/Library/Scripts/Applications/Evernote
  2. I turned on the menu in Script Editor > Preferences.
    5aab780d1e86c_ScreenShot2018-03-16at00_47_42.png.38e7e0e95982a05d77ac2229cd3d0dfc.png.3a056a613a3efab020cb23482db15ca4.png

Share this post


Link to post

Script - Identify OS folder the note contents are stored in.5aad69753c843_ScreenShot2018-03-17at12_11_55.png.b2983c9c684c5301b436bc5f11150fbf.png

On a Mac, each note's content is stored in a separate OS folder.
The top level folder can be identified using Option Key Help > Troubleshooting

 

The metadata is stored in database LocalNoteStore.sqllite
The contents of each note are stored in <some folder> and includes:

  • file content.enml
  • attachments5aabeaa332e1f_ScreenShot2018-03-16at09_02_16.png.335a74946ca446621042c56c5760dd8d.png
  • other files (snippet, card image, ...)

 

The script I use to identify <some folder> is below
Evernote_Note_Folder.scpt
Note, the database folder is hardcoded; update this for your own installation

Note: For external edits, the data accessed is a copy of the master version maintained on the Evernote servers.  After verifying my update, l make a dummy change (like adding a space in the note).  This ensures the update gets registered and sync'd to the server

5ab3034a91d7f_ScreenShot2018-03-21at18_13_00.png.cf917e358f20cffe3ba61689ffab7108.png

 

Share this post


Link to post
5 hours ago, michaelbierman said:

Yup. Another option is to go to System Preferences > Keyboard > Services and you can set a keyboard shortcut of your own choosing. I made some minor improvements yesterday and uploaded them to github. 

I actually bought a program Fastscripts that assigns a keyboard shortcut to any script.

It works great, but I discovered I can't remember all these shortcuts; so most of  the time I refer to a menu

  • Like 1

Share this post


Link to post

Script: Import from a CSV file

 

  • Like 1

Share this post


Link to post

For automatic scheduling, I use the Mac LaunchAgents feature to launch scripts at a scheduled time.
This includes my morning alarm script, and daily backup script.

There's documentat at https://en.wikipedia.org/wiki/Launchd 
but basically it's a .plist file in folder /Users/david/Library/LaunchAgents
5ab3fb13262bc_ScreenShot2018-03-22at11_50_37.png.be96a8cd16de5ab91f2007b022a979b1.png

 

I use app Lingon to simplify the setup

5ab3fa6381469_ScreenShot2018-03-22at11_45_58.png.764d89b65aa7b4fd24b2373831515397.png

 

Share this post


Link to post

Script: Boilerplate code for processing notes5abd4cd86635c_ScreenShot2018-03-29at13_27_24.png.8f6a5f6885fb2994f2432d4e81310140.png

The example shows procesing for

  1. Selected Notes; 
  2. Notes meeting a search query

Share this post


Link to post
On 3/16/2018 at 9:20 AM, DTLow said:

Two points about the storage and access of Applescripts.5aab78258ccd5_ScreenShot2018-03-16at00_49_45.thumb.png.10509ddb69ff81b4f1c00638cb209b0f.png.a905a79d06a4547e34494e8cbae34573.png.0472805c3f3cae1f81e8619ef13f184a.png

I show a menu of scripts in my top menu bar.

  1. I store the Evernote scripts in folder /Users/<user>/Library/Scripts/Applications/Evernote
  2. I turned on the menu in Script Editor > Preferences.
    5aab780d1e86c_ScreenShot2018-03-16at00_47_42.png.38e7e0e95982a05d77ac2229cd3d0dfc.png.3a056a613a3efab020cb23482db15ca4.png

This is awesome! How did you get the Evernote Scripts section to appear on the dropdown of the scripts tool in the top toolbar? Asking for a friend. 

Share this post


Link to post
10 minutes ago, Sprintup said:

How did you get the Evernote Scripts section to appear on the dropdown of the scripts tool in the top toolbar?

The scripts are filed in a separate folder for each application and displayed for whatever application is open.5aedd4999fc1d_ScreenShot2018-05-05at08_57_08.png.9506c6527541ea0df6f5f4592ffc28fc.png
If you're working in Evernote, you see the Evernote scripts.

Share this post


Link to post

Script - Backup Evernote Data

The backup uses the export feature with the code

try
with timeout of (10 * 60) seconds
     
export theNotes to fileBackup format HTML
end timeout
end try

For selection criteria, my daily incremental backups use    set theNotes to find notes ("updated:day-1 -updated:day")
My weekly full backups are a more complicated; a separate export is required for each notebook

set allNotebooks to every notebook
repeat with currentNotebook in allNotebooks
     set notebookName to (the name of currentNotebook)
     set theNotes to every note in notebook notebookName
end repeat

Share this post


Link to post

Script - Append Metadata To Note Contents

Currently the metadata is not stored with the note contents.  1448312769_ScreenShot2018-09-04at12_05_05.png.93754c44da4636378ff4760d597e5108.png
On a Mac, the metadata is stored separately in an sqlite database
My objective is to have this data always available, so I append a copy to the bottom of each note

The script runs nightly for all new/changed notes, or on a one-of basis

 

set thedate to modification date of theNote

set newText to "<hr/>"
set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">Title: " & title of theNote & "</span></span></div>"
set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">Notebook: " & name of notebook of theNote & "</span></span></div>"
set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">"
set newText to newText & "Updated:  ud" & my FormatDate(modification date of theNote)
set newText to newText & "   Created: cd" & my FormatDate(creation date of theNote)
set newText to newText & "   Subject: sd" & my FormatDate(subject date of theNote)
set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">"
set newText to newText & "Reminder: rd" & my FormatDate(reminder time of theNote)
set newText to newText & "   Completed:  xd" & my FormatDate(reminder done time of theNote)|
set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">"
set newText to newText & "<div><span style=\"color: rgb(4, 51, 255);\"><span style=\"font-size: 12px;\">"
set theTags to tags of theNote
repeat with theTag in theTags
     
set theTagName to name of theTag
     
set newText to newText & "Tag: " & theTagName & "   "
end repeat

 append theNote html newText
set modification date of theNote to thedate

Share this post


Link to post

Hi! I was wondering if there is a way to have the tag of a note change based on it's reminder time. For example if I create a note with the tag "scheduled" and set the reminder to April 5. I want the tag to change from "scheduled" to "open" on April 5th. Can this easily be done? 

 

Share this post


Link to post
On 9/14/2018 at 12:26 PM, Ben68982 said:

Hi! I was wondering if there is a way to have the tag of a note change based on it's reminder time. For example if I create a note with the tag "scheduled" and set the reminder to April 5. I want the tag to change from "scheduled" to "open" on April 5th. Can this easily be done? 

Sorry to have overlooked the post.

Yes, it's easy to use scriting to retrieve the reminder time and assign tags
The actual commands are 

set theReminderTime to reminder time of theNote
assign tag theTag to theNote
unassign tag theTag from theNote

>>I want the tag to change from "scheduled" to "open"

Instead of tag "scheduled", we can use search  reminderOrder:* or ReminderTime:*
                   tag "Open" , we can use search  -reminderOrder:* or -ReminderTime:* (negation)

I'm a tagger, but I don't want to duplicate the trigger; I use Reminders to identify my tasks, open or scheduled

 

 
  •  

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

×