Sorry for my ignorance - I’m a new DevonThink Pro user, and one of the things I use DT for is to archive web pages that infringe the copyright of my photographs.
I have one group which contains 26 web clips, saved as web archives.
I need to export all 26 URL’s as text links to paste into a DMCA take-down letter, but I can’t for the life of me seem to figure out how to do it…
I don’t need them exporting as web pages - though that’s simple enough… I JUST need to be able to select a number of entries in the group, and export the ‘URL’ field to a document, clipboard, or other app…
I just discovered there is an ‘export Metadata as CSV’ script available - sadly though, it seems incorrect as it doesn’t create a correctly formatted CSV… it uses semicolons as delimeters and adds a delimeter at the end of each record, so I’ve reworked it so that it uses commas instead, and doesn’t end each line with an extra comma.
Thanks for the bug report! Here’s a revised script, its output is compatible to DEVONthink Pro, Numbers, Microsoft Excel and Quick Look.
-- Export Metadata (Name, URL, Comment, Tags & Annotations) as double-quoted CSV.
-- Created by Christian Grunenberg on Fri Dec 03 2010.
-- Copyright (c) 2010-2013. All rights reserved.
property pSeparator : ";"
tell application id "com.devon-technologies.thinkpro2"
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 "\"Name\";\"URL\";\"Comments\";\"Tags\";\"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_annotation, theseTags
tell application id "com.devon-technologies.thinkpro2"
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)
set this_URL to URL of this_record as string
if this_URL begins with "x-devonthink-item://" then
set this_csv to this_csv & my prepareCSV("", pSeparator)
set this_URL to (characters 21 thru -1 of this_URL) as string
else
set this_csv to this_csv & my prepareCSV(this_URL, pSeparator)
set this_URL to ""
end if
set this_csv to this_csv & my prepareCSV(comment of this_record as string, pSeparator)
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)
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) and (this_annotation is not missing value) then
set this_csv to this_csv & my prepareCSV(this_annotation, return)
else
set this_csv to this_csv & my prepareCSV("", return)
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)
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
return "\"" & theString & "\"" & theSeparator
end prepareCSV
Thanks for this script.
Does a more recent script exist working with DevonThink3 and making use of new features, like custom metadata?? I’d like to export some information into csv and would like to include different metadata (custom meta data fields), tags and even a directlink to the specific file.