For documents which I don’t regularly receive, my workflow is as follows:
scan document to DT global inbox
classify document by selecting a suggested group in See Also & Classify
from the sidebar select the database and group I have just sent the document to
see how I named the previous versions of that document
rename the document I have just added to fit the pattern used previously
I do have a fixed naming convention, and in many cases documents are automatically renamed on that basis; in many other cases I can rename based on the convention. But a number of outliers remain.
Is there any way I can jump to (ie show) the group I have just moved a document to? Or is there a variable in script (last used group or something of the kind?) That would speed up the above workflow no end. And that’s what it’s all about…
This script opens parent 1 of the last added record.
Not sure if that’s useful in your workflow, but as moving a record doesn’t change the modification date of a group this seems to be the nearest you’ll get.
-- Open parent 1 of last added record
tell application id "DNtp"
try
set currDate to current date
set theComparisonDate to currDate - 86400
set theDatabases to databases
repeat with thisDatabase in theDatabases
set thisDatabasesResults to search "additionDate >" & theComparisonDate in (root of thisDatabase)
if thisDatabasesResults ≠ {} then
repeat with i from (count thisDatabasesResults) to 1 by -1
set theRecord to item i in thisDatabasesResults
if type of theRecord is not in {group, smart group} and type of parent 1 of theRecord is not feed then
set thisDatabasesLastAdded to theRecord
exit repeat
end if
end repeat
try
if (addition date of thisDatabasesLastAdded) ≥ theComparisonDate then
set theComparisonDate to (addition date of thisDatabasesLastAdded)
set globalLastAdded to thisDatabasesLastAdded
end if
end try
end if
end repeat
open window for record (parent 1) of globalLastAdded
activate
on error error_message number error_number
if the error_number is not -128 then
display alert "DEVONthink 3" & space & error_number message error_message as warning
end if
end try
end tell
Thank you for that. I’m going to make spaghetti with mushrooms and tomato sauce now. Would you like some? When I’ve done that, I’m going to have a beer. And when I’ve done that, I’m going to implement your script as a little button. And as I don’t have to write it myself, I’ve got the evening off
Is there any way of opening the group in the current window rather than opening a new one? (edit: on second thoughts it’s probably actually more convenient having it open in a new window, and closing that with ⌘W when I’ve finished).
getting better all the time - is there a way to define the bounds of the window which is opened within the open command? I know how to do it as a separate command with set the bounds of window - but that is optically less pleasing, because the window opens and then moves. What I want to do is open the second window a number of pixels to the right and down from the original window - so it appears stacked. I’ve tried simply adding bounds or with bounds but that isn’t recognised.
if viewer window 1 exists then
set theBounds to bounds of viewer window 1
set newWindow to open window for record parent 1 of globalLastAdded
set bounds of newWindow to {(item 1 of theBounds) + 22, (item 2 of theBounds) + 22, ((item 3 of theBounds) + 22), (item 4 of theBounds) + 22}
else
set newWindow to open window for record parent 1 of globalLastAdded
end if
set selection of newWindow to {globalLastAdded}
activate