This script is a mash-up of 2 or 3 different scripts that korm and Christian have done. (Plus my own little twists)
I wanted to generate an indented list of links that could serve as an index. @korm, I commented out your code for selecting “Whole Database” because I wasn’t sure what would happen if someone used it on a multi-gigabyte database. There must be a limit somewhere for the clipboard!?
An example of the output:
-- Create 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
--Modified 11_08_2013 by clane47 to create a list of links of the selected groups/files
--If you REALLY want the option to generate links to every group and doc in your database,
--then uncomment the code.
--This is mostly a mash-up of some of korm's scripts + a few twists of my own.
--Remember, the result is on the clipboard ready to be pasted into a document.
--In particular though, I like Christian's recursive subroutine!
global o_HTML
tell application id "com.devon-technologies.thinkpro2"
try
if not (exists current database) then error "No database is open."
set theDatabase to the current database
show progress indicator "Creating Listing..."
--set listScope to button returned of (display dialog "Scope of Group Listing" buttons {"Whole Database", "Selected Group and Children", "Cancel"} default button 1 cancel button 3 with title "Put a Group Listing on the Clipboard")
--
--if listScope is "Whole Database" then
-- my createListing(children of root of theDatabase, "")
-- set o_RTFLink to (do shell script "echo " & o_HTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf" as rich text)
--else if listScope is "Selected Group and Children" then
set rootGroup to the current group
my createListing(rootGroup, "")
set o_RTFLink to (do shell script "echo " & o_HTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf" as rich text)
--else
-- return
--end if
hide progress indicator
on error error_message number error_number
hide progress indicator
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell
on createListing(theseRecords, theTabs)
local this_record, this_type, this_listing, this_name
tell application id "com.devon-technologies.thinkpro2"
set o_HTML to ""
repeat with this_record in theseRecords
set this_name to (name of this_record as string)
set thisURL to the reference URL of this_record
set o_HTML to o_HTML & quoted form of (theTabs & "<font face=\"helvetica\"><a href=\"" & thisURL & "\">" & this_name & "</a></font> </br>")
step progress indicator this_name
set o_HTML to o_HTML & my createListing(children of this_record, theTabs & " " & " " & " " & " " & " ")
end repeat
end tell
return o_HTML
end createListing