How could I create a txt or rtf list of all groups and sub-groups names and item links?

Would it be asking too much to modify your script below from oct 2020 so that group and sub-group names are followed by their link ?

If I am asking too much of your time, no problem !

thank you

source

script

-- Create Group Listing
-- Created by Christian Grunenberg on Sun Jul 24 2005.
-- Copyright (c) 2005-2009. All rights reserved.
-- Modified 20130602 to capture only groups
-- Modified by @clane47 11_01_2013 to capture only groups to a rich text file
-- Modified by @korm 20131102 to put the listing on the clipboard for pasting elsewhere
-- Additional modification 20131102 to optionally set base group for the listing to the selected group
-- Improved error handling and much higher performance by Christian Grunenberg on Wed Oct 28 2020

tell application id "DNtp"
	try
		if not (exists current database) then error "No database is open."
		
		set listScope to button returned of (display dialog "Scope of Group Listing" buttons {"Whole Database", "Selected Group and SubGroups", "Cancel"} default button 1 cancel button 3 with title "Put a Group Listing on the Clipboard")
		
		show progress indicator "Creating Listing..." with cancel button
		
		if listScope is "Whole Database" then
			set the clipboard to my createListing(children of root of current database whose type is group, "")
		else if listScope is "Selected Group and SubGroups" then
			set the clipboard to my createListing(children of current group whose type is group, "")
		else
			error -128 -- Cancelled
		end if
		
		hide progress indicator
		
		display notification "Listing in clipboard!" with title "Create Listing"
	on error error_message number error_number
		hide progress indicator
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

on createListing(theseGroups, theTabs)
	local this_group, this_listing, this_name, nextTabs
	tell application id "DNtp"
		set this_listing to ""
		set nextTabs to theTabs & (ASCII character 9)
		repeat with this_group in theseGroups
			set this_name to (name of this_group as string)
			set this_listing to this_listing & theTabs & this_name & return
			step progress indicator this_name
			set this_listing to this_listing & my createListing(children of this_group whose type is group, nextTabs)
			if cancelled progress then error -128
		end repeat
	end tell
	return this_listing
end createListing
1 Like