I’m not a programmer, so I can’t see what’s wrong with this simple script that I’ve been using in OF1 to link directly to mirror project folders on my hard drive (actually a dropbox folder). Anyone else using this script and have a version updated for the new Applescript requirements? Thanks. John. Here’s the script:
--Written by Jim Harrison, Dec 2008 (jhh.med.virginia.edu). May be used, edited and redistributed without restriction.
--Opens folders at a specified location that have the same name as an OmniFocus project that contains the selection
--Edit the name and path below to correspond to the location of the main Projects folder that will contain the individual project folders
set projectsFolderName to "Projects" -- name for main projects folder
set projectsPath to (path to home folder as text) & "Dropbox" & ":" -- path to main projects folder
tell front window of application "OmniFocus" -- get the name of the project containing the current selection
try
set theTrees to the selected trees of content
if the (count of theTrees) is less than 1 then
set theTrees to the selected trees of sidebar
end if
if the (count of theTrees) is less than 1 then
display dialog "To open a project folder, click on or in a project, task or note before running this script"
return
end if
set theSelection to value of item 1 of theTrees
if the class of theSelection is folder then
set thisProjPath to the name of theSelection
set theGroup to the container of theSelection
else
set thisProjPath to the name of the containing project of theSelection
set theGroup to the container of the containing project of theSelection
end if
repeat while the class of theGroup is not document
set thisProjPath to the name of theGroup & ":" & thisProjPath
set theGroup to the container of theGroup
end repeat
on error
display dialog "Click on or in a project, task or note before running this script." buttons {"OK"} default button 1
return
end try
end tell
tell application "Finder"
activate
try
open folder (projectsPath & projectsFolderName & ":" & thisProjPath & ":")
on error
try
if not (folder (projectsPath & projectsFolderName & ":") exists) then
set answer to display dialog "Create new main projects folder at " & projectsPath & " called \"" & projectsFolderName & "?\"" buttons {"Cancel", "OK"} default button 1
if the button returned of answer is "Cancel" then return
make new folder at projectsPath with properties {name:projectsFolderName}
end if
set oldDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
repeat with i from 1 to (count of text items in thisProjPath)
if i = 1 then
set containingFolder to projectsFolderName
set subPath to ""
else
set containingFolder to text item (i - 1) of thisProjPath
set subPath to (text items 1 thru (i - 1) of thisProjPath as text) & ":"
end if
if not (folder (projectsPath & projectsFolderName & ":" & subPath & text item i of thisProjPath) exists) then
set answer to display dialog "Create new folder \"" & text item i of thisProjPath & "\" in the " & containingFolder & " folder?" buttons {"Cancel", "OK"} default button 1
if the button returned of answer is "Cancel" then return
make new folder at alias (projectsPath & projectsFolderName & ":" & subPath) with properties {name:text item i of thisProjPath}
end if
end repeat
set AppleScript's text item delimiters to oldDelimiter
open folder (projectsPath & projectsFolderName & ":" & thisProjPath & ":")
on error
return
end try
end try
end tell