View Single Post
OK still working on this folderAction. I would like to learn how to add a Project and a Context to a task. The code below is working just like I want except I would like to add a default project of "Miscellaneous" and a default context of "Unassigned" Thanks for any insight you may provide.

d


Code:
on adding folder items to my_folder after receiving the_files
	repeat with i from 1 to number of items in the_files
		tell application "OmniFocus"
			launch
			try
				set this_file to (item i of the_files)
				tell application "Finder"
					activate
					open document file this_file using application file "Tex-Edit Plus.app" of folder "Tex-Edit Plus" of folder "Applications" of startup disk
					tell application "Tex-Edit Plus"
						activate
						delete text from line 1 to line 7 of window 1
						select contents of window 1
						set singleTask to false
						set theText to contents of window 1
						close window 1 without saving
						tell application "OmniFocus"
							set singleTask to true
							tell default document
								set myNewTasks to parse tasks with transport text theText as single task singleTask
							end tell
							set start date of first item of myNewTasks to (current date) + 1 * days
							set due date of first item of myNewTasks to (current date) + 4 * days
						end tell
					end tell
				end tell
				add this_file
			end try
		end tell
	end repeat
end adding folder items to