I was using Devonthink and Omnifocus at the same time, and I wrote two scripts with the help of my friend. The first script allowed me to create a folder with the same name for the tasks in Omnifocus and write the task’s ID to the comment of this folder, and the second script was to open this folder with Finder
The first script looks like this
tell application "OmniFocus"
tell default document
tell the front document window
set theItem to selected tree of content
set thePath to POSIX file "/Users/Fuguexv/Library/Mobile Documents/com~apple~CloudDocs/2022AU/2022AU_Inbox" as alias
repeat with thisItem in theItem
set folderName to name of thisItem
set folderId to id of thisItem
tell application "Finder"
activate
make new folder at thePath with properties {name:(folderName), comment:(folderId)}
end tell
end repeat
say "OK"
end tell
end tell
end tell
The second script looks like this
tell application "OmniFocus"
tell default document
tell the front document window
set theTask to selected tree of content
repeat with thisTask in theTask
set taskId to id of thisTask
tell application "Finder"
activate
set rootFolder to POSIX file "/Users/Fuguexv/Library/Mobile Documents/com~apple~CloudDocs/2022AU" as alias
set theTaskFolder to entire contents of rootFolder
repeat with thisTaskFolder in theTaskFolder
set folderComment to comment of thisTaskFolder
if taskId contains folderComment then
reveal thisTaskFolder
end if
end repeat
end tell
end repeat
end tell
end tell
end tell
Now I want to use Devonthink to open this folder, I tried to modify the second script but it didn’t work, I hope someone can help me to see what the problem is ~ thanks for your help!
My failed script looks like this
tell application "OmniFocus"
tell default document
tell the front document window
set theTask to selected tree of content
repeat with thisTask in theTask
set taskId to id of thisTask
tell application id "DNtp"
set theRecord to lookup records with comment taskId
repeat thisRecord in theRecord times
open window for record thisRecord
end repeat
end tell
end repeat
end tell
end tell
end tell