One part of my workflow is to lock documents and move them to an archive group. That was getting tedious so I wrote a simple applescript to automate it. Sharing it here in case someone else might find it useful. Also it’s the first applescript I’ve ever written (for DT or otherwise) so if you’ve got suggestions for improvement, let me know
p.s. you need to have a group in your database named “archive” - the script doesn’t automatically create one
-- Mark document as locked and move to archive group
-- Created by Pat Maddox on Fri Oct 1 2010
-- Released under Creative Commons Attribution-ShareAlike license
-- http://creativecommons.org/licenses/by-sa/3.0/
-- (that means that you can do basically whatever you want with this :)
try
tell application "DEVONthink Pro"
set this_selection to the selection
if this_selection is {} then error "Please select some contents."
set archive_group to (get record at "archive")
repeat with this_record in this_selection
if (uuid of this_record is not equal to uuid of archive_group) and (name of this_record is not equal to "Inbox") and (name of this_record is not equal to "Sync") and (name of this_record is not equal to "Tags") then
set locking of this_record to true
move record this_record to archive_group
end if
end repeat
end tell
on error error_message number error_number
if the error_number is not -128 then
try
display alert "DEVONthink Pro" message error_message as warning
on error number error_number
if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
end try
end if
end try
set archive_group to display group selector "Archive to Where?"
For this code
set archive_group to (get record at "archive")
DT will open the group selector HUD, where you can chose any group in any open database as your target group for the “archive”, including the option to create a new group on the fly.
Cool. I don’t want the group selector but I’ve added it as a comment for others.
I also added a prompt that lets me add it to my reading list. I use a “To Read” label and then a smart group to display my reading list. Updated script will archive the selected records, and if you choose to add it to the Reading List it will also apply the label, and add a “clipping” tag.
When I go through my reading list, I just have to remove the “To Read” label to get it off my reading list, and it is already in my archive. Of course if I have no desire to keep it around I can just delete it. But I can also start to clip quotes or take notes on it.
btw is there a way to specify the label by name, rather than by index?
-- Mark document as locked and move to archive group
-- Created by Pat Maddox on Fri Oct 1 2010
-- Released under Creative Commons Attribution-ShareAlike license
-- http://creativecommons.org/licenses/by-sa/3.0/
-- (that means that you can do basically whatever you want with this :)
try
tell application "DEVONthink Pro"
set this_selection to the selection
if this_selection is {} then error "Please select some contents."
set archive_group to (get record at "archive")
-- uncomment the next line to prompt for location instead
-- set archive_group to display group selector "Archive to Where?"
end tell
set archiveType to choose from list {"Reading List"} with prompt "Add to..."
tell application "DEVONthink Pro"
repeat with this_record in this_selection
if (uuid of this_record is not equal to uuid of archive_group) and (name of this_record is not equal to "Inbox") and (name of this_record is not equal to "Sync") and (name of this_record is not equal to "Tags") then
set locking of this_record to true
move record this_record to archive_group
if archiveType contains "Reading List" then
set label of this_record to 3
if the tags of this_record does not contain "clipping" then
set the tags of this_record to the tags of this_record & "clipping"
end if
end if
end if
end repeat
end tell
on error error_message number error_number
if the error_number is not -128 then
try
display alert "DEVONthink Pro" message error_message as warning
on error number error_number
if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
end try
end if
end try
No. The label property is an integer index; name cannot be specified. The label array is maintained in Preferences, as you know, and using the index to that array ensures that if you changed a label from “To Read” to “To Read When I’m at the Beach” your scripts don’t break.