The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Applescript access to attachments ? Thread Tools Search this Thread Display Modes
There is a table listing attached files in the cache.

You should be able to read it like this:

Code:
on run
	tell application "OmniFocus"
		tell front document window of default document
			set lstID to id of selected trees of content where class of value = task or class of value = inbox task
			if length of lstID < 1 then return
			set strTaskID to first item of lstID
		end tell
	end tell
	
	
	AttachmentList(strTaskID)
end run

on AttachmentList(strTaskID)
	set strCMD to "sqlite3 ~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2 'select name from Attachment where task=\"" & strTaskID & "\"'"
	paragraphs of (do shell script strCMD)
end AttachmentList
 
Wow, you drill into the SQLite database directly! Thatís awesome, thanks!

Is this documented anywhere, perchance?
 
OK, now Iíve got a note containing File Attachments that I can save, and an sqlite table containing the filenames of the attachments, but I canít figure out how to pair them up. Which filename goes with which File Attachment?

Any tips? It would be easy if the File Attachment object had a persistentIdentifier property or something that showed up in the sqlite table.
 
name is only one of the fields in the table.
persistentIdentifier text,
containingTransactionHint text,
context text,
creationOrdinal integer,
dateAdded timestamp NOT NULL,
dateModified timestamp NOT NULL,
folder text,
name text,
perspective text,
previewPNGData blob,
task text
The OmniFocus.ofocus package contains various zip files.
The name of the zip file containing the attachment is given by the field containingTransactionHint.

If the relevant file is unzipped, you will find that it contains a folder named data, containing subfolders with unique names. The persistentIdentifier fields gives the name of the subfolder containing the file specified in the record.

--

Last edited by RobTrew; 2011-03-23 at 02:24 PM..
 
Quote:
Originally Posted by RobTrew View Post
name is only one of the fields in the tableÖ
Thanks for the added detail! Iím still stumped on how to match up the File Attachments visible to my AppleScript to the file names present in the Attachments table, however.

The Support Ninjas tell me that
Code:
get file name of aFileAttachment
should work. Iíve reported the fact that it doesnít work with embedded attachments as a bug.
 
Quote:
Originally Posted by Kevin Yank View Post
Iím still stumped on how to match up the File Attachments visible to my AppleScript to the file names present in the Attachments table
Do you need to ? I would have thought that all you need from the applescript is the id of the task/project.

From there the information in the cache will take you straight to the files ...
 
Ah, I see what you mean! Ignore the AppleScript File Attachment objects entirely and rely on the sqlite database to enumerate and locate the file attachments.

I could see that working, but Iím trying to write an AppleScript that I can invoke to send the selected task(s) (and their attachments) to another application. Unzipping the transaction file for each task to access the attachments seems like it would be a slow and inefficient process for what Iím trying to achieve.

Iíll wait and see what the Ninjas say about the apparent bug in their AppleScript support for attachments. Failing that, Iíll take another look at drilling into that database.

Thanks again!
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access "Wrap To Shape" property from Applescript? Sophie OmniGraffle General 12 2013-01-19 08:50 PM
AppleScript Access to Change Tracking bjmclaughlin OmniPlan Extras 0 2012-03-07 03:55 AM
Applescript access to tasks in inbox dmcg OmniFocus Extras 2 2009-01-09 08:44 AM
Applescript access to natural language date parsing? RobTrew OmniFocus Extras 3 2007-12-27 12:22 PM
Web Access chrjohns OmniFocus 1 for Mac 0 2007-02-19 09:41 AM


All times are GMT -8. The time now is 06:43 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.