Capture a link/page to the Inbox (or wherever)

I use DT as my browser, and like to save a lot of links I come across for later reading and filing, without spending time to open them first. However, DT in its current incarnation will only “capture” them to the folder I happen to be in – not to the folder I designate. For anyone else who finds this frustrating, this workaround may be of some use (at least until DT offers the option of designating a destination folder for internal “captures”, as they do for incoming links from other apps).

First, control-click on the link to call up the contextual menu, as you would to “capture link.” But instead select “Copy link.” Then run this script:

tell application "DEVONthink Pro"
	set theURL to the clipboard
	set theSource to download markup from theURL
	set theLink to create record with {type:html, source:theSource, URL:theURL} in incoming group
end tell

Presto - the page for the link will be saved , complete with title, to your Inbox, or to whatever other destination you designate in place of “incoming group.” Obviously if you wished you could just save the link [create record with {type:bookmark,URL:theURL}] but I haven’t been able to figure out a way to save the name of the page along with it. Whereas when you save the whole page DT does it for you.

Of course, if you do have a bunch of saved links, see my script for converting bookmarks to their associated web pages: viewtopic.php?f=20&t=8442

This script stores a link using the right title:

tell application "DEVONthink Pro"
	set theURL to the clipboard
	set theSource to download markup from theURL
	set theTitle to get title of theSource
	create record with {type:bookmark, name:theTitle, URL:theURL} in incoming group
end tell

Ah. Of course. Thanks!


I must be doing something wrong but I can’t figure out what, since this is so simple!

I’ve cut and pasted both “acoyne’s” and Christian’s scripts in the Script editor, saved them to the Safari scripts folder, selected and copied the URL in the URL field above, selected both scripts separately from within FastScripts, and it appeared that nothing occurred.

I checked the global inbox and lo! there they were. I was never presented with a dialog box asking where I wanted to drop these URLs.

Oops, I think I see: I’m using Safari rather than DTPO as my browser. Silly me.

Any tips on how to alter this to work using Safari?


Yeah – just wrap it with ```

tell application “Safari”

at the beginning and

end tell

well. I added the wrapping you suggested to both scripts and still no dialog box when I invoke either script.

Thanks for the suggestion, though.

Huh? There shouldn’t be any dialogue box. The script should just save the bookmark or web page, without further input required.

acoyne, I’m sorry :blush: , I think I totally misunderstood something. I thought the idea was to be able to specify at the time of invoking the script where we users wanted to drop it instead of the global inbox.

Now it appears, through some closer reading of your original post, that the script needs to include a specific folder and indeed, there is no dialog box, though that would be extremely helpful.

Thanks for your insight.

That’s easy. In place of this:

 create record with {type:html, source:theSource, URL:theURL} in incoming group

Insert this:

set theGroup to display group selector "Clip page to:" buttons {"Cancel", "OK"}
	create record with {type:html, source:theSource, URL:the_url} in theGroup

That’s if you’re saving the full page. The code for saving a link is adapted in the same way.

I don’t suppose there’s a way of eliminating the contextual-menu step, is there? That is, a script command to copy the URL of whatever link the mouse is hovering over?

That’s not possible. But a completely different approach might be to simply copy the link (using whatever application/browser you like), then use “New with clipboard” of DEVONthink’s Dock menu and select the desired destination.