Skip to content

Instantly share code, notes, and snippets.

@adamwalz
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamwalz/27943f597ea759167fca to your computer and use it in GitHub Desktop.
Save adamwalz/27943f597ea759167fca to your computer and use it in GitHub Desktop.
#!/usr/bin/osascript
------------------------------------------------------------------------------
-- FILE: pocket_to_evernote_clipper.scpt
-- DESCRIPTION: Imports all clips from Pocket into Evernote through the
-- Evernote Web Clipper for Safari
-- AUTHOR: Adam Walz <awalz@evernote.com>
-- VERSION: 1.1.0
--
-- This script takes a file containing a list of urls, one per line, and
-- imports the urls into Evernote by similuating use of the Evernote Web
-- Clipper for Safari. The list of urls can be found by using the Pocket
-- export tool.
--
-- By default, the script uses the Clearly ("Simplified Article") style in the
-- Clipper, but this can be changed. It is also possible to change this script
-- from using Safari to using Chrome.
--
------------------------------------------------------------------------------
set clippingStyle to "C" -- Clearly simplified article
-- set clippingStyle to "A" -- Full article style
-- get the text file containing all urls to clip
set urlListFile to choose file
set urlList to paragraphs of (read urlListFile)
tell application "Safari"
activate
make new document
end tell
repeat with currentUrl in urlList
tell application "Safari"
set URL of front document to currentUrl
delay 2
end tell
tell application "System Events"
tell process "Safari"
keystroke "`"
delay 1
keystroke clippingStyle
delay 1
key code 36
delay 4
end tell
end tell
end repeat
@adamwalz
Copy link
Author

This script is conservative with its use of delay. I don't know is the delay times are too long, so feel free to change them.

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