Create Bookmark with AppleScript

Hi all, hoping you might be able to point me in the right direction with this script I’ve been using.

    set paragraph_list to read file "Macintosh HD:Users:jcsullivan2:Desktop:URL2PDF.txt" using delimiter linefeed
    set theName to item 1 of paragraph_list
    set theURL to item 2 of paragraph_list
    tell application id "DNtp"
        set theRecord to create PDF document from theURL name theName pagination no
    end tell
end try

I use this to create a PDF from the URL in the text file. I am hoping to modify this script to allow me to create a bookmark record. I searched the AppleScript dictionary for a bookmark and didn’t come up with anything, so I don’t think there is a create bookmark but is there something else I can do to create the bookmark?

I have one other request (as I barely hobbled the above together) which is if there is a way to have more than one URL in the file per line and the script run through however many lines/URLs and create a PDF for each one. Thank you for any help you can provide.

Here are the basics of creating a Bookmark via AppleScript…

tell application id "DNtp"
	set urlName to "DEVONtech"
	set urlURL to ""
	create record with {name:urlName, URL:urlURL, type:bookmark} in incoming group
end tell

As far as processing multiple entities in the text file, yes it’s possible but it’s also highly dependent on the structure, and uniformity of data, in that file. A screencap or example would be helpful.

It’s good to see you learning some AppleScript too! :smiley:

Thank you for that, I’ll try that. Is it possible based on my previous request regarding the PDF to do this for multiple bookmarks or would I need to set the URL on line 1 then the name as line 2?

Usually in the file is only 1 line which is the URL I want to change to a PDF.

I’ve included a screenshot of what I would like to do, which has 1 URL on each line, but multiple URLs/Lines in the document which gets processed per line:

Thank you,

Yes, this is possible to do (and more than one way to approach it). Here is a simple example…

set currentText to (read "/Users/yourUsername/Desktop/URLTest.txt”) — I just used the POSIX (UNIX) path here.

tell application id "DNtp"
	repeat with thisParagraph in (paragraphs of currentText)
			set theRecord to create PDF document from thisParagraph pagination no in current group
	end repeat
end tell

Okay, so I got that script working perfectly so thank you so much!

And the bookmark script I got working with line one being the urlName and line two being the URL.

My only question then is if there is an easy way to put multiple URLs in the text file and have DEVONthink grab the page name from the URL like the create PDF document does?

If it’s not easy, can I suggest DEVONtech add Create Bookmark to the AppleScript, in the same way, Create PDF works?

Thank you for your time and patience.