tell application "Evernote" set _sel to selection if _sel ≠ {} then set theNote to first item of _sel set theURL to (note link of theNote) end if end tell set ENcode to "echo \"" & theURL & "\" | sed -E 's#https?://www.evernote.com/shard/(..)/(..)?/([0-9]*)/(.*-.*-.*-.*-.*)/?.*#evernote:///view/\\3/s2/\\4\\4#' | tr '\\n' ' ' | tr -d '[[:space:]]' | pbcopy" do shell script ENcode