Export comments

Is there a way to export the comments of several entries simultaneously?

Try this to create a CSV containing the record name (document name) and the comment.


-- Export comments from a selection of documents to a CSV file
-- Comments with quotation makes will have the quotes stripped out

tell application id "com.devon-technologies.thinkpro2"
	try
		-- Make a selection
		set this_database to current database
		set these_items to the selection
		if these_items is {} then error "Please select some contents"
		
		-- Initiate the output
		set theFile_name to choose file name with prompt "Export" default name (name of this_database as string) & ".csv"
		set theOutput to "record, comment" & return
		
		-- Make an output line for each record that has a comment
		repeat with this_item in these_items
			if (comment of this_item) is not equal to "" then
				set this_line to (name of this_item as string) & ", " & (comment of this_item as string) & return
				set theOutput to theOutput & this_line
			end if
		end repeat
		
		-- Write the output to the file
		set theFile to open for access theFile_name with write permission
		if (get eof of theFile) > 0 then
			set eof of theFile to 0
		end if
		set theOutput to theOutput as Unicode text
		write theOutput to theFile
		close access theFile
		
		-- Error handler
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

Create a script file. Install into the script menu. (See the help file). Make a selection in the document list. Run the script.

Could be modified to do a TSV or plain TXT, RTF, etc., or to make a sheet in DT, or…

It works

Thank you very much