Create a DEVONthink bookmark for the current PDF page

I wrote an AppleScript for creating a DEVONthink bookmark for the current PDF page. The bookmark currently is created either in the group in which the PDF is inside (when the PDF is selected and you use the Tree Panes View) or at the top of the current database (when you read the PDF in a seperate DEVONthink window).

The code is the following:


tell application "DEVONthink Pro"
	set nameCurrentPDF to name of content record of window 1
	--for removing the extension
	set charFullStop to character -4 of nameCurrentPDF
	if charFullStop is "." then set nameCurrentPDF to characters 1 thru -5 of nameCurrentPDF as text
	set DEVONthinkPageNum to current page of window 1
	set realCurrentPageNum to DEVONthinkPageNum + 1
	set DEVONthinkPage to DEVONthinkPageNum as text
	set realCurrentPage to realCurrentPageNum as text
	set fileLink to the reference URL of content record of window 1
	create record with {type:bookmark, name:nameCurrentPDF & " - p. " & realCurrentPage, URL:fileLink & "?page=" & DEVONthinkPage} in current group
	
end tell

I would like to add the ability to select the group in which the bookmark will be created by navigating the tree structure of the groups using the GUI interface. The selection can be made before or after the execution of the script.

Any help would be appreciated!

Change the last statement as follows:


create record with {type:bookmark, name:nameCurrentPDF & " - p. " & realCurrentPage, URL:fileLink & "?page=" & DEVONthinkPage} in display group selector

The Group Selector will open - it is similar to the HUD that is opened with Tools > Show Groups & Tags. Select the group and your script will create the record there.

Thank you very much Korm!

I should mention an alternative structure.

set targetGroup to display group selector
create record ... in targetGroup