A few months ago I wrote a script to capture entries from feeds subscribed to in DevonThink.
I use it as follows: I select the first entry of the feed in DEVONThink and decide whether or not I want to import the associated web page. When I want to import the page I press the down arrow key to advance to the next feed, when I don’t want to import the page I press delete to remove the entry from the feed. When I have ‘read’ all the entries in the feed, I select the feed and let the script import the entries.
I hope this script is useful to some of you.
Copy the script, paste it in a new window in your AppleScript Editor and save it in Script format under an appropriate name (what about ‘Capture entries from selected feeds’?) in a convenient temporary place (such as the desktop or your downloads folder). Open DEVONThink, select ‘Open Scripts Folder’ in its Scripts menu and drag your new script from its convenient temporary place to DEVONThink’s ‘Scripts’ folder or one of its subfolders (can I suggest the ‘Feeds’ subfolder?). Return to DEVONThink, choose ‘Update Scripts Menu’ and you are ready.
To use it select a feed in your database and activate the script in DEVONThink’s Scripts menu.
-------------------------------------------------------------------------
-- capture entries from selected feeds
-- Arno Wouters, 5 January 2013
-------------------------------------------------------------------------
tell application id "com.devon-technologies.thinkpro2"
try
set theSelection to the selection as reference
on error errMsg number errnum
if errnum = -1700 then
error "Please select one or more feeds before running this script."
else
error "An unexpected error occurred: " & return & return & "Error " & errnum & ": " & errMsg & return
end if
end try
repeat with thisFeed in theSelection
if (type of thisFeed) is feed then
set theDatabase to the database of theSelection
set theTrash to the trash group of theDatabase
set theDestination to the parent of thisFeed as reference
set FeedEntries to the children of thisFeed
repeat with thisEntry in FeedEntries
set theurl to the URL of thisEntry
create web document from theurl in theDestination
move record thisEntry to theTrash
end repeat
end if
end repeat
end tell
A few days ago Jeff Porter from Wordius called my attention to Pinboard’s RSS feeds. It occurred to me that these feeds can be used to send articles from my iPad to DEVONThink. After all, all the relevant apps on my iPad (Mr. Reader, Instapaper, iCab mobile and Safari) allow me to bookmark pages on pinboard and tag them with ‘todevon’. So I created an RSS feed with the name ‘Pinboard’ in DEVONThink’s global inbox to capture the bookmarks tagged to ‘todevon’ and modified the above script to automatically import the bookmarked pages when activated (no need to select the feed before calling the script).
This is the modified script:
-------------------------------------------------------------------------
-- capture entries from Pinboard's feed
-- Arno Wouters, 4 July 2013
-------------------------------------------------------------------------
-- set the properties needed to locate the relevant feed
-------------------------------------------------------------------------
-- 1) set nameofDatabase to the name of the database that contains the feed
-- use "" if the feed is in the global inbox
set nameofDatabase to ""
-- 2) set pathtoFeed to the path to the feed
-- e.g. the path to the feed 'Pinboard feed' in the 'My feeds' group is
-- "/My feeds/Pinboard feed"
set pathtoFeed to "/Pinboard"
-------------------------------------------------------------------------
-- don't change anything below this heading
-------------------------------------------------------------------------
tell application id "com.devon-technologies.thinkpro2"
if nameofDatabase is "" then
set theDatabase to inbox -- the global inbox
else
set theDatabase to database named nameofDatabase
end if
set theTrash to the trash group of theDatabase
set theFeed to get record at pathtoFeed in theDatabase
set theDestination to incoming group of theDatabase
set FeedEntries to the children of theFeed
repeat with thisEntry in FeedEntries
set theurl to the URL of thisEntry
create web document from theurl in theDestination
move record thisEntry to theTrash
end repeat
end tell
-------------------------------------------------------------------------
As it is, this script works with the feed “Pinboard” at the root level of the global inbox. To use it with a feed with another name or at another location you have to modify the first two lines of the script in your AppleScript Editor:
-
in the first active line of the script (set nameofDatabase to “”): put the name of your database between the quotes (if your database is named ‘My Database’ this line should read: set nameofDatabase to “My Database”)
-
in the second active line of the script (set pathtoFeed to “/Pinboard”) replace /Pinboard with the path to your feed (if the script should capture the entries of the feed ‘Instapaper’ in the ‘My Feeds’ group, this line should read: set pathtoFeed to “/My Feeds/Instapaper”)
Don’t change anything else!
Comments, criticisms and suggestions for improvement are welcome!