wondering what I should change for this script to work with DT3
“Activate and open last entry”
@korm if you are reading please let me know. Thanks.
tell application id "DevonThink 3"
try
set theAge to (3600 * 24)
set theComparisonDate to (current date) - theAge
set theDatabases to databases
repeat with thisDatabase in theDatabases
set thisDatabasesResults to search age theAge in (root of thisDatabase)
if thisDatabasesResults ≠ {} then
set thisDatabasesLastAdded to item -1 of thisDatabasesResults
if (addition date of thisDatabasesLastAdded) ≥ theComparisonDate then
set theComparisonDate to (addition date of thisDatabasesLastAdded)
set globalLastAdded to thisDatabasesLastAdded
end if
end if
end repeat
open window for record globalLastAdded
activate
on error error_message number error_number
if error_number is -2753 then display notification "Im angegebenen Zeitraum wurde nichts hinzugefügt" with title "DEVONthink"
end try
end tell
-- Open last added record (DEVONthink 3)
property alwaysOpenInDocumentWindow : true
tell application id "DNtp"
try
set currDate to current date
set theComparisonDate to currDate - 86400 -- 24 hours
set theDatabases to databases
repeat with thisDatabase in theDatabases
set thisDatabasesResults to search "additionDate >" & theComparisonDate in (root of thisDatabase)
if thisDatabasesResults ≠ {} then
set thisDatabasesLastAdded to item -1 of thisDatabasesResults
if (addition date of thisDatabasesLastAdded) ≥ theComparisonDate then
set theComparisonDate to (addition date of thisDatabasesLastAdded)
set globalLastAdded to thisDatabasesLastAdded
end if
end if
end repeat
if alwaysOpenInDocumentWindow = true then
set theDocWins to every document window
repeat with thisDocWin in theDocWins
if content record of thisDocWin = globalLastAdded then
set thisDocsIndex to index of thisDocWin
tell application "System Events" to tell process "DEVONthink 3"
perform action "AXRaise" of window thisDocsIndex
end tell
activate
return
end if
end repeat
open tab for record globalLastAdded
activate
else
open window for record globalLastAdded
activate
end if
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
HI Korm, Pete updated it, with so many scripts I don’t who made what.
Thanks anyway
BTW one of these days I will share a workflow you might be interested. I know by the looks of it you are always looking for smart ways to make things convenient. If you are into trackpad you will like it but if you are more of a keyboard type of guy you may or may not be interested lol
I guarantee 100% nobody has this and works awesomely good with DevonThink it’s almost too perfect.