Importing a list of URLs as bookmarks

I am looking to use DevonThink as my bookmark reader/archiver/tagger.

I have downloaded a json file with all of my Pinboard links, and have parsed it out to one long text file with one URL per line.

Is it possible to flip through all of these items and create a bookmark for each one?


Welcome @sergio_101

Check out the Script menu > Import > Pinboard script to see if that helps.

oh! totally didn’t know that existed…

unfortunately, all it does is create an empty group called “Pinboard”…

This script creates a bookmark for each line of the selected records.

If you’re dealing with a large number of URLs it might be that you have to set a delay inside the repeat loop in order to get bookmarks with proper names (not sure this is necessary, but I think after a script already added hundreds of bookmarks the last ones didn’t get a proper name anymore).

-- Create bookmarks from text

tell application id "DNtp"
		if not (exists viewer window 1) then error "Please select a record"
		set theRecords to selection of viewer window 1
		if theRecords = {} then error "Nothing selected"
		set theGroup to display group selector "Create bookmarks in:"
		repeat with thisRecord in theRecords
			set theText to plain text of thisRecord
			set theURLs to paragraphs of theText
			repeat with thisURL in theURLs
				set thisURL to thisURL as string
				if thisURL ≠ "" then
					create record with {type:bookmark, URL:thisURL} in theGroup
					#delay 1
				end if
			end repeat
		end repeat
		open window for record theGroup
	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

This makes sense. it looks like i have 12,730 bookmarks that it’s trying to import.


In this case I would definitely split the file in e.g. 500 or 1000 line files.