Script Creates Evernote Note & Calendar Reminder w/Link

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

I’ve come up with an Applescript that will save a document to Evernote and also create a Calendar event as a reminder to follow-up in seven days. The Calendar entry also contains a link to the note. If you use Evernote on an iOS device, the link will open Evernote and the note.

In order to use the Applescript as is, you need to create the following:

  • A folder named “Save PDF to Inquiries” in ~/Library/PDF Services/
  • A Calendar called “To Do” in the Calendar application. The event created by the Applescript will be an all day event. I have the default alarm for all day events set at 9:00am in Calendar preferences.
  • Create a notebook in Evernote called "Inquiries"
In the print dialog, select "Save PDF to Inquiries" from the PDF drop down menu to start the process.

I’m not a coder, so what this Applescript achieves could likely have been done in a much more efficient manner. Please feel free to make suggestions.

Enjoy…

Image

Evernote Inquiry.scpt

Code: Select all
on hazelProcessFile(theFile)
   tell application "System Events"
      display dialog "Enter Note Title" default answer ""
      set noteTitle to text returned of result
      
      tell application id "com.evernote.Evernote"
         synchronize
         delay 5
         
         create note from file theFile notebook {"Inquiries"} title {noteTitle} tags {"Inquiry"}
         
         set worklogs to find notes "tag:Inquiry"
         set newestLog to item 1 of worklogs
         repeat with worklog in worklogs
            if creation date of worklog is greater than creation date of newestLog then
               set newestLog to worklog
            end if
         end repeat
         synchronize
         delay 2
         set noteURL to note link of newestLog
         delay 2
      end tell
      
      tell application "Calendar"
         tell calendar "To Do"
            set theDate to ((current date) + 7 * days)
            set newEvent to make new event at end with properties {description:"Evernote Inquiry", summary:"EN: " & noteTitle, start date:theDate, end date:theDate, url:noteURL, allday event:true, status:confirmed}
         end tell
      end tell
   end tell
end hazelProcessFile
EdBurke
 
Posts: 28
Joined: Wed Apr 18, 2012 6:58 am

Here's a shell script to auto-create the folder in PDF services:

Code: Select all
if [ -d ${HOME}/Library/PDF\ Services/Save\ PDF\ to\ Inquiries ]
then
   echo "Folder already created"
else
   mkdir -p ${HOME}/Library/PDF\ Services/Save\ PDF\ to\ Inquiries
    

fi
kevnm67
 
Posts: 3
Joined: Sat Nov 29, 2014 11:33 pm


Return to Tips & Tricks - DO NOT POST QUESTIONS