View Single Post
When using AppleScript to access and save out file attachments embedded in the note of an OmniFocus task, you need to specify the type (or filename extension) of the file to save, but as far as I can tell there is no way of identifying the type of a file attachment.

Based on what I’m seeing, when accessing embedded file attachments, you can’t obtain the attachment’s filename. All you have access to is the file attachment object, which responds to the 'save' command, which requires you to specify a new filename.

I have a file attachment export AppleScript almost working. The only problem left is that it saves the files with no type, and therefore Mac OS X doesn’t know what to make of them.

Code:
tell note of theTask
	set NumberOfFileAttached to number of file attachment
	set i to 1
	set ListOfPaths to {}
	repeat while i ≤ NumberOfFileAttached
		if file attachment i is embedded then
			set tempFilePath to my pathForTemporaryFile("OmniFocus")
			tell file attachment i
				save in tempFilePath
			end tell
			set end of ListOfPaths to tempFilePath
		else
			set end of ListOfPaths to file name of file attachment i as string
		end if
		set i to i + 1
	end repeat
end tell
Is getting the necessary information about the file attachment simply not possible with OmniFocus 1.8.2? That would make me very, very sad. :(

Last edited by Kevin Yank; 2011-03-23 at 04:50 AM..