Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JMichaelTX/8c88642d54f085352d611d8af8d26ef1 to your computer and use it in GitHub Desktop.
Save JMichaelTX/8c88642d54f085352d611d8af8d26ef1 to your computer and use it in GitHub Desktop.
Create an .inetloc File to open Evernote Note in Evernote Mac app using AppleScript.
property ptyScriptName : "Create Internet Location File from EN Note"
property ptyScriptVer : "2.0"
property ptyScriptDate : "2018-03-29"
property ptyScriptAuthor : "JMichaelTX"
(*
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REQUIRED:
1. macOS 10.11.6+
2. Mac Applications
• Evernote Mac 6.11.1+
• Finder
INSTALLATION: See http://tinyurl.com/install-as
BUG/ISSUE REPORTS:
• Find any bugs/issues or have suggestions for improvement?
• Contact me via PM in Evernote Forum or at blog.jmichaeltx.com/contact/
TAGS: @Lang.AS @SW.EN @CAT.Files @CAT.Link @CAT.Notes @Auth.JMichaelTX
REF: The following were used in some way in the writing of this script.
1. Can't find reference
I think I got this idea from someone in the Evernote Forum, but I can't find it now.
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*)
use framework "Foundation"
use framework "AppKit"
use scripting additions
try ---------------- TRY --------------------
tell application "Evernote"
set lstSelectedNotes to selection
if lstSelectedNotes ≠ {} then
set oNote to first item of lstSelectedNotes
set strNoteTitle to title of oNote
set strNoteLink to note link of oNote
my createWebLocFile(strNoteLink, strNoteTitle)
set scriptResults to "OK"
end if
end tell -- Evernote
--------------- END TRY ---------------------------------
on error errMsg number errNum
if errNum = -128 then ## User Canceled
set errMsg to "[USER_CANCELED]"
end if
set scriptResults to "[ERROR]" & return & errMsg & return & return ¬
& "SCRIPT: " & ptyScriptName & " Ver: " & ptyScriptVer & return ¬
& "Error Number: " & errNum
end try ---------------- END TRY/ERROR BLOCK ------------------------
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END OF MAIN SCRIPT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
on createWebLocFile(pstrNoteLink, pstrNoteTitle)
(* VER: 2.0 2018-03-29
---------------------------------------------------------------------------------
PURPOSE: Create Internet Location Files for Evernote Note Classic Link
PARAMETERS:
• pstrNoteLink ┃ text ┃ EN Note Classic Link
• pstrNoteTitle ┃ text ┃ EN Note Title (will be file name)
RETURNS: nothing
AUTHOR: JMichaelTX
—————————————————————————————————————————————————————————————————————————————————
*)
local filePath, fileAlias
set strPrompt to "Choose FOLDER For Note: " & pstrNoteTitle
tell application "Evernote" to set aliFolder to choose folder with prompt strPrompt
tell application "Finder"
set fileName to pstrNoteTitle & " [EN Note]"
set aliFile to make new internet location file to pstrNoteLink at (aliFolder) with properties {name:fileName}
set fileAlias to aliFile as alias
set filePath to POSIX path of (fileAlias)
end tell -- application "Finder"
--- Set Path to Evernote Icon in Evernote App --
set imagePath to "/Applications/Evernote.app/Contents/Resources/Evernote.icns"
--- Set File Icon to Evernote Icon ---
set theImage to (current application's NSImage's alloc()'s initWithContentsOfFile:imagePath)
(current application's NSWorkspace's sharedWorkspace()'s setIcon:theImage forFile:filePath options:0)
tell application "Finder"
activate
reveal aliFile
end tell
end createWebLocFile
--~~~~~~~~~~~~~~~ END OF handler createWebLocFile ~~~~~~~~~~~~~~~~~~~~~~~~~
@JMichaelTX
Copy link
Author

@ccstone
Copy link

ccstone commented Mar 19, 2019

Hey JM,

Looks interesting...

-ccs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment