Download links of page… but as bookmarks!

The “Download :arrow_right: Links of Page” entry in DEVONthink’s Scripts menu is great, but it’s meant for downloading the actual contents of those links using the Download Manager, usually as HTML pages. What if you just want bookmarks?

I modified its “Add Links.scpt” AppleScript to do it. You can save the script below or download it from iCloud.

-- Add links as bookmarks
-- modified by Mark Gardner from "Add Links.scpt" by Christian Grunenberg 
-- Original Copyright (c) 2004-2014. All rights reserved.

tell application id "DNtp"
	try
		if not (exists think window 1) then error "No window is open."
		set this_window to think window 1
		set this_URL to the URL of this_window
		set these_links to get links of (the source of this_window) ¬
			as string base URL this_URL
		if the (count of these_links) is 0 ¬
			then error "No links in this document"
		set group_name to the name of content record of this_window
		set link_group to create record with ¬
			{type:group, URL:this_URL, name:group_name} in current group
		repeat with this_link in these_links
			create record with {type:bookmark, URL:this_link} in link_group
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert ¬
			"DEVONthink" message error_message as warning
	end try
end tell
1 Like

Thanks for sharing this script! Another possibility is to use the Document > Links inspector, select all links in the upper pane via the contextual menu and finally drag them to the desired group.

2 Likes