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: OF Project as OpenMeta file tag Thread Tools Search this Thread Display Modes
I thought this script might be useful for any other users of tagging software based on the OpenMeta standard. The script allows the user to choose from a list of active project names from OmniFocus and apply the chosen project name as an OpenMeta tag to selected files in the Finder. You can also opt to use any arbitrary text string for the tag.

I think I stole the code for the handler that pulls the project list from a script that someone else on these forums wrote, but I can't remember who. If this is your code, please let me know and I'll credit you (or pull the code if you prefer, though I hope you won't).

Update: the code was from Rob Trew!
Attached Files
File Type: zip Tag for Project...1.2.scpt.zip (6.5 KB, 347 views)

Last edited by eurobubba; 2011-05-04 at 12:27 PM..
 
The ProjNames() functions is something which I sketched before OF 1.9, and it is no longer required.

The new flattened projects collection is now all you need:

Code:
tell application "OmniFocus"
	set oDoc to default document
	set my text item delimiters to ASCII character 10
	
	set projNames to (name of (flattened projects of oDoc where hidden of its folder is false and its status is active)) as string
	
	set my text item delimiters to space
	set projNames to do shell script "echo " & quoted form of projNames & " | sort -f"
end tell
 
Thanks! I've updated the script with the new code and a comment crediting you. Attached the new version to the original message above.
 
The fastest approach, which works even when OmniFocus is not running, is likely to be:

Code:
set strProjects to do shell script "sqlite3 ~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2 " & ¬
	quoted form of "select tp.name from (task t join projectinfo p on t.projectinfo=p.pk) tp left join folder f on tp.folder=f.persistentidentifier where f.active=1 and tp.status='active'  order by tp.name"
This may not, however, be very future-proof, as the cache schema can change from one build of OF to another.

--

Last edited by RobTrew; 2011-05-03 at 08:33 PM..
 
OmniFocus not running? (Scratches head in puzzlement....)
 
It crashes now and then, you know :-)
 
Code:
set projNames to do shell script "echo " & quoted form of projNames & " | sort -f"
That does not yield an AppleScript list...
Suggested:

Code:
set projNames to paragraphs of (do shell script "echo " & quoted form of projNames & " | sort -f")
 
Nice optimization, thanks! Eliminates the text item delimiters do-si-do after the original version.
 
Quote:
Originally Posted by RobTrew View Post
The ProjNames() functions is something which I sketched before OF 1.9, and it is no longer required.

The new flattened projects collection is now all you need:

Code:
tell application "OmniFocus"
	set oDoc to default document
	set my text item delimiters to ASCII character 10
	
	set projNames to (name of (flattened projects of oDoc where hidden of its folder is false and its status is active)) as string
	
	set my text item delimiters to space
	set projNames to do shell script "echo " & quoted form of projNames & " | sort -f"
end tell
I am trying to have a column in OO display a list of all projects and another column display a list of all contexts in OF. Can this script be modified to show all contexts? I tried substituting "all contexts" for all projects, but got an error message -

"Can’t make name of every «class FCfc» of document id \"gBlhvZFrou-\" of application \"OmniFocus\" whose «class FCHi» of «class FCAr» = false and «class FCPs» = «constant FCPsFCPa» into type string." number -1700 from name of every «class FCfc» of document id "gBlhvZFrou-" whose «class FCHi» of «class FCAr» = false and «class FCPs» = «constant ****FCPa» to string
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using OpenMeta to tag Projects and tasks imlad OmniFocus 1 for Mac 3 2011-09-03 07:41 AM
(Partial) OpenMeta support in OmniFocus – great or stinkin’? nggalai OmniFocus 1 for Mac 23 2010-10-06 06:13 AM
New file via Applescript: do I have this right? Eponymous OmniOutliner 3 for Mac 2 2009-01-31 10:09 AM
Applescript example: exporting to a text file RobTrew OmniFocus Extras 6 2007-09-11 08:27 PM
Using Applescript to Attach File BillB OmniOutliner 3 for Mac 1 2007-04-16 03:55 PM


All times are GMT -8. The time now is 12:58 PM.


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