AppleScript: OF Project as OpenMeta file tag
1 Attachment(s)
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). [I]Update: the code was from Rob Trew![/I] |
The ProjNames() functions is something which I sketched before OF 1.9, and it is no longer required.
The new [I]flattened projects[/I] 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[/CODE] |
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"[/CODE] This may not, however, be very future-proof, as the cache schema can change from one build of OF to another. [COLOR="White"]--[/COLOR] |
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"
[/CODE] That does not yield an AppleScript list... Suggested: [CODE]set projNames to paragraphs of (do shell script "echo " & quoted form of projNames & " | sort -f") [/CODE] |
Nice optimization, thanks! Eliminates the text item delimiters do-si-do after the original version.
|
Can the list of context be gotten in a similar way?
[QUOTE=RobTrew;96726]The ProjNames() functions is something which I sketched before OF 1.9, and it is no longer required.
The new [I]flattened projects[/I] 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[/CODE][/QUOTE] 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 |
All times are GMT -8. The time now is 12:07 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.