Move file to OF inbox with hazel

I’ve looked all over (including this forum) for something that should be very simple I think?

I would like to move a file to the OF inbox as an attachment to a task, with the task title being the filename.

Using Hazel and an Applescript it should not be so hard, should it?

But I can find a solution opening the quick entry window, but not a totally unattended one.

Does anyone know somewhere I can look for help?
Or does someone have an applescript to do this?

I recommend checking out this MacSparky post:

It’s from 2012…but last I checked it still worked like a charm.

I don’t think it’s exactly what you’re looking for, but hopefully it will help lead to a solution. Personally I’m not a fan of storing files in OmniFocus. Instead, I prefer to store them in a cloud storage solution (e.g. Dropbox, iCloud) and reference them from OmniFocus.

I hope this helps!

1 Like

Here is an AppleScript I hacked together some time ago (probably in part using the MacSparky script above) and use from Hazel to add various bank statements and things to OmniFocus. It’s probably not perfect, but it seems to work and sounds like it will do what you need to do with only minor tweaking.

I note that lines 2-3 use custom tokens that have been pulled from the file, so obviously if you don’t want to use those you would just delete those lines (and if you want to use something else, more tweaking!)

tell application "OmniFocus"
	set Amount to item 1 of inputAttributes
	set due_date to item 2 of inputAttributes
	set task_title to "Pay Bank CC ($" & Amount & ")"
	tell front document
		set theProject to first flattened project where its name = "[Bills]"
		tell theProject
			set NewTask to make new task with properties {name:task_title, due date:due_date}
			tell the note of NewTask
				make new file attachment with properties {file name:theFile, embedded:true}
			end tell
		end tell
	end tell
end tell

I copied this script and put it into Script Editor and on compile it automatically converted “context” to “tag.” That was a nice little bit of magic, whether it was Omni’s doing or the Script Editor developers’. Either way, it put a smile on my face.

1 Like

Thanks Kaitlin! Worked like a charm. I changed some minor things to suit my workflow, and the script itself works perfectly.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.