How to create a new project in a specific folder

I want to be able to create a new Project in OF2 through AppleScript (this will be alongside creating a series of folders in Finder and mailboxes in Mail (essentially I want to create a series of things once I decide I need to focus on something.

I got the various Finder scripts working, but can’t see how to do this in OF2. I have the OF2 data file (I think) located on a hard drive called ‘Content’. I have tried both of the following:

(1)
make new project at folder “/Volumes/Content/Torchy/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Application Support/OmniFocus/OmniFocus.ofocus/Personal” with properties {id:“New Prospect”}

(2)
make new project at folder “Personal” of folder “OmniFocus.ofocus” of folder “OmniFocus” of folder “Application Support” of folder “Library” of folder “Data” of folder “com.omnigroup.OmniFocus2” of folder “Containers” of folder “Library” of folder “Torchy” of disk “Content” with properties {id:“New Prospect”}

Both come up with errors:

(1) Compiles, but on run gives this:

error “OmniFocus got an error: Can’t get folder “/Volumes/Content/Torchy/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Application Support/OmniFocus/OmniFocus.ofocus/Personal”.” number -1728 from folder “/Volumes/Content/Torchy/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Application Support/OmniFocus/OmniFocus.ofocus/Personal”

(2) Doesn’t compile and gives this:

Expected end of line, etc. but found “"”. (With the error on the first " of Content

Once those of you who know what you’re doing stop laughing, could you maybe point me in the right direction.

Thanks,

David

OmniFocus folders are totally different from Finder folders. I think you want something more like this:

tell application "OmniFocus"
	tell default document
		set theFolder to folder named "Personal"
		tell theFolder
			make new project with properties {name:"New Prospect"}
		end tell
	end tell
end tell

In general, I find it very difficult to guess how to AppleScript a new app. I find it much much easier to read existing AppleScripts for that app and find one close to what I’m doing, and borrow/steal/hack/modify it to do what I need.

1 Like