Korn
Thanks for the reply. Apologies for the delay in replying to you.
The creation of a Table of Contents provides a workaround and it may suffice.
The script that Christian previously provided was:
– Customizable Metadata Export
– Created by Christian Grunenberg on Fri Jun 06 2014.
– Copyright © 2010-2014. All rights reserved.
property pSeparator : “;”
property pKind : true
property pDateCreated : true
property pURL : true
property pTags : true
property pComments : true
property pAnnotations : true
property pAuthor : true
property pRecipient : true
tell application id “DNtp”
try
set theSelection to the selection
if theSelection is {} then error “Please select some documents.”
set theFile to choose file name default name “Export.csv”
show progress indicator "Exporting..."
set theCSV to my prepareCSV("Name", pSeparator)
if (pKind) then set theCSV to theCSV & my prepareCSV("Kind", pSeparator)
if (pDateCreated) then set theCSV to theCSV & my prepareCSV("Date Created", pSeparator)
if (pAuthor) then set theCSV to theCSV & my prepareCSV("Author", pSeparator)
if (pRecipient) then set theCSV to theCSV & my prepareCSV("Recipient", pSeparator)
if (pURL) then set theCSV to theCSV & my prepareCSV("URL", pSeparator)
if (pTags) then set theCSV to theCSV & my prepareCSV("Tags", pSeparator)
if (pComments) then set theCSV to theCSV & my prepareCSV("Comments", pSeparator)
if (pAnnotations) then set theCSV to theCSV & my prepareCSV("Annotations", return)
set theCSV to theCSV & my createCSV(theSelection)
set thePath to POSIX path of theFile
if thePath does not end with ".csv" then set thePath to thePath & ".csv"
do shell script "echo " & quoted form of theCSV & ">" & quoted form of thePath
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 createCSV(theseRecords)
local this_record, this_csv, this_name, this_URL, this_metadata, this_author, this_recipient, this_annotation, theseTags
tell application id “DNtp”
set this_csv to “”
repeat with this_record in theseRecords
set this_name to name of this_record as string
set this_csv to this_csv & my prepareCSV(this_name, pSeparator)
if (pKind) then set this_csv to this_csv & my prepareCSV(kind of this_record as string, pSeparator)
if (pDateCreated) then set this_csv to this_csv & my prepareCSV(creation date of this_record as string, pSeparator)
if (pAuthor or pRecipient) then
set this_metadata to meta data of this_record
if (pAuthor) then
try
set this_author to |kMDItemAuthors| of this_metadata
on error
try
set this_author to |kMDItemAuthorEmailAddresses| of this_metadata
on error
set this_author to ""
end try
end try
if exists this_author then
set this_csv to this_csv & my prepareCSV(this_author, pSeparator)
else
set this_csv to this_csv & my prepareCSV("", pSeparator)
end if
end if
if (pRecipient) then
try
set this_recipient to |kMDItemRecipients| of this_metadata
on error
try
set this_recipient to |kMDItemRecipientEmailAddresses| of this_metadata
on error
set this_recipient to ""
end try
end try
if exists this_recipient then
set this_csv to this_csv & my prepareCSV(this_recipient, pSeparator)
else
set this_csv to this_csv & my prepareCSV("", pSeparator)
end if
end if
end if
set this_URL to URL of this_record as string
if this_URL begins with "x-devonthink-item://" then
if (pURL) then set this_csv to this_csv & my prepareCSV("", pSeparator)
set this_URL to (characters 21 thru -1 of this_URL) as string
else
if (pURL) then set this_csv to this_csv & my prepareCSV(this_URL, pSeparator)
set this_URL to ""
end if
if (pTags) then
set {od, text item delimiters of AppleScript} to {text item delimiters of AppleScript, return}
set theseTags to (tags of this_record) as string
set text item delimiters of AppleScript to od
set this_csv to this_csv & my prepareCSV(theseTags, pSeparator)
end if
if (pComments) then set this_csv to this_csv & my prepareCSV(comment of this_record as string, pSeparator)
if (pAnnotations) then
if this_URL is not "" then
set this_annotation to plain text of (get record with uuid this_URL)
else
set this_annotation to ""
end if
if exists this_annotation then
set this_csv to this_csv & my prepareCSV(this_annotation, return)
else
set this_csv to this_csv & my prepareCSV("", return)
end if
end if
if type of this_record is group or type of this_record is feed then
step progress indicator this_name
set this_csv to this_csv & my createCSV(children of this_record)
end if
end repeat
end tell
return this_csv
end createCSV
on prepareCSV(theString, theSeparator)
try
if theString contains “”" then
local od
set {od, text item delimiters of AppleScript} to {text item delimiters of AppleScript, “”"}
set theString to text items of theString
set text item delimiters of AppleScript to “”""
set theString to “” & theString
set text item delimiters of AppleScript to od
end if
on error
set theString to “”
end try
return “”" & theString & “”" & theSeparator
end prepareCSV