Guest
2010-05-31, 01:30 AM
Quote:
Originally Posted by Tukanuk
I'd like to write an Applescript to allow me to create a shortcut to focus on a particular folder which is hardwired into the script.
|
It would be helpful if the
Complete function (which quickly finds projects and contexts by name) supported folders as well, but this draft (which searches recursively for the named folder) may be in the region of what you need.
(The first line needs to be edited to specify the name of a folder)
Code:
property pstrFolderName : "EDIT THIS STRING TO NAME OF A FOLDER"
property pstrTitle : "Focus on folder"
tell application "OmniFocus"
set oDoc to default document
set oFolder to my FolderByName(oDoc, pstrFolderName)
if oFolder is not missing value then
set focus of front document window of oDoc to {oFolder}
else
display dialog "Folder name: " & ¬
pstrFolderName & return & "not found" with title pstrTitle
end if
end tell
on FolderByName(oParent, strName)
using terms from application "OmniFocus"
set lstMatches to folders of oParent where name is strName
if length of lstMatches > 0 then
return first item of lstMatches
else
set lstFolders to folders of oParent
repeat with oFolder in lstFolders
set varResult to FolderByName(oFolder, strName)
if varResult is not missing value then return varResult
end repeat
end if
return missing value
end using terms from
end FolderByName
--
Last edited by RobTrew; 2010-05-31 at 04:19 PM..