View Single Post
Quote:
Originally Posted by RobTrew View Post
No problem easily done.



Perhaps something along these lines:

Code:
tell application "Finder" to set file_name to (name of theFile)

set dteBase to current date
set theNote to "Scanned " & (dteBase as string) & " 

"
set projectname to "Proceed Files"

set ContextName to "Some Context"

set theTask to "Proceed: \"" & file_name & "\""

tell application "OmniFocus"
	set task_title to theTask
	tell default document
		-- GET A REFERENCE TO AN EXISTING PROJECT (OR NEW) PROJECT 
		set lstProj to flattened projects where name = projectname
		if lstProj ≠ {} then
			set oProj to item 1 of lstProj
		else
			set oProj to (make new project with properties {name:projectname})
		end if
		
		-- GET A REFERENCE TO AN EXISTING (OR NEW) CONTEXT
		set lstContexts to flattened contexts where name = ContextName
		if lstContexts ≠ {} then
			set oContext to item 1 of lstContexts
		else
			set oContext to (make new context with properties {name:ContextName})
		end if
		
		-- MAKE A NEW TASK UNDER THE SPECIFIED PROJECT, 
		-- ATTACHING IT TO THE SPECIFIED CONTEXT
		-- AND STAMPING IT WITH A START DATE
		
		set dteStart to dteBase - (time of dteBase) -- zero the time to midnight
		set dteStart to dteStart + (3 * days) -- and add three days
		
		tell oProj
			tell (make new task with properties {name:task_title, context:oContext, start date:dteStart})
				set its note to theNote
				tell its note to make new file attachment with properties {file name:file_name, embedded:false}
			end tell
		end tell
	end tell
end tell
Thanks a lot Rob! This works perfectly and will give me some more spare time :-)

@Dale: thanks for your help as well!
But I don't get this. Why do i want to add 8 * hours? Do i have to add 72 instead of hours if i want 3 days? :)

Quote:
Originally Posted by Dale View Post
To modify the time change the number of hours using 24hour time in the this line of code.

Code:
set time of theStartDate to 0 + (8 * hours)