Page 1 of 2
set up direct access to OmniFocus projects

Posted:
Mon Aug 06, 2012 9:48 pm
by ecormany
i'm a new OmniFocus user. i really like it, and i hoped that i could directly access projects via my launcher app of choice, LaunchBar, but this isn't the case. curiously, you can do that with Spotlight. the reason is that OF keeps files that link to projects in a cache folder (~Library/Caches/Metadata/com.omnigroup.OmniFocus), but their filenames are non-descriptive hashes. the reason they show up nicely in Spotlight is because their Title attribute is set to the name of the project. Hazel to the rescue.
- Code: Select all
if all of the following conditions are met for the file or folder being matched
Kind is OmniFocus Project Metadata
Date Added is after Date Last Matched
Title matches [• project title]
do the following
Make alias in folder OmniFocus Projects
Rename with pattern [• project title]
the rule creates aliases to the project files in a separate folder and renames them with their Title attribute. add that folder to the LaunchBar index and you now have direct access to projects by name.
the only shortcoming right now is that it doesn't work for projects with a / character in the title, due to limitations on Hazel's rename functionality. if anyone has a workaround for that, i'd love to add it to the rule!
Re: set up direct access to OmniFocus projects

Posted:
Tue Aug 07, 2012 3:23 pm
by Mr_Noodle
Hazel shouldn't have any problem renaming files with "/" in them (just tested it). I suggest you email support with specifics if it isn't working for you.
Keep in mind, though, that in Finder, "/" actually is a ":" when viewed at a lower level (like in Terminal). One way to look at it is in Finder-land, ":" is used to separate folders in a path whereas in Terminal-land, it's "/".
Re: set up direct access to OmniFocus projects

Posted:
Fri Aug 17, 2012 10:27 am
by ecormany
just tested this. it looks like / is not getting escaped or converted to : properly. i even tried creating an OF project with a : in the title, and that didn't cause an error, and its alias showed up in the Finder displaying a /
here's the log for an error thrown by a project named "test / project 2":
- Code: Select all
2012-08-17 10:18:53.885 hazelworker[12362] adNSHgTX6zy.ofocus-project-metadata: Rule create named aliases in Docs subfolder matched.
2012-08-17 10:18:53.913 hazelworker[12362] [File Event] Alias created: Created alias for file /Users/ed/Library/Caches/Metadata/com.omnigroup.OmniFocus/adNSHgTX6zy.ofocus-project-metadata in folder /Users/ed/Documents/OmniFocus Projects.
2012-08-17 10:18:54.035 hazelworker[12362] Error creating FSRef for path /Users/ed/Documents/OmniFocus Projects/test : -43 - File not found
2012-08-17 10:18:54.035 hazelworker[12362] Move path failed. Could not get FSRef for destination path /Users/ed/Documents/OmniFocus Projects/test .
2012-08-17 10:18:54.036 hazelworker[12362] [Error] File rename failed: Could not rename /Users/ed/Documents/OmniFocus Projects/adNSHgTX6zy-1.ofocus-project-metadata to test / project 2.
also, i don't think this happened when i was originally testing this rule, but as written above, projects with / in the title will actually trigger an infinite loop. i'm guessing it's because when Hazel throws an error it doesn't mark the file as Matched, so it keeps trying (and failing) over and over again?
Re: set up direct access to OmniFocus projects

Posted:
Fri Aug 17, 2012 12:27 pm
by Mr_Noodle
Actually, there might be an issue with the alias and rename actions. It should work for copy and move though. I'm looking into it.
Re: set up direct access to OmniFocus projects

Posted:
Fri Aug 17, 2012 1:58 pm
by Mr_Noodle
Ok, I think the problem here is that the / is being introduced via a custom token so it is not getting escaped. For comparison purposes, if you just do a rename and type in a / directly into the pattern, it will work correctly. I'll look into fixing it for the next patch.
Re: set up direct access to OmniFocus projects

Posted:
Mon Aug 20, 2012 4:22 pm
by ecormany
excellent, thanks! i had to pass it as a token because the new name depends on an extended attribute of the original file. (my first attempt at writing the rule just tried to do rename with Title and it tried to pull a Title attribute from the alias, which obviously had none!)
Re: set up direct access to OmniFocus projects

Posted:
Wed Feb 27, 2013 6:36 pm
by masterninja01
Wow, this is one piece that I've been looking for to enhance quicksilver and OF.
But, I still don't get you entered for the token "project title" or how you entered it.
Re: set up direct access to OmniFocus projects

Posted:
Fri Mar 01, 2013 5:20 pm
by Mr_Noodle
It's a custom token. I'm guessing it's just set to be (...) so it captures the full title field.
Re: set up direct access to OmniFocus projects

Posted:
Sat Mar 23, 2013 11:02 pm
by chrisWhite
I'm loving this ecormany, thanks for posting it!
By any chance has anyone found a way to automatically delete the aliases for projects that have been finished or deleted?
Re: set up direct access to OmniFocus projects

Posted:
Mon Oct 21, 2013 4:16 pm
by mlondon
Hi,
Hazel newbie here...
Sorry, but I need a little help with this.
- Which "Folder" should I place this in in Hazels pref-pane?
- Do I have to do anything to trigger it the first time? What causes this list of alias's to be built so LaunchBar can find them?
- Then do I need to setup a LaunchBar index rule to find them?
Thank yuou !
Re: set up direct access to OmniFocus projects

Posted:
Mon Dec 09, 2013 8:50 pm
by pickerin
mlondon wrote:- Which "Folder" should I place this in in Hazels pref-pane?
You want to add the folder:
/Users/YOURUSERNAME/Library/Caches/Metadata/com.omnigroup.OmniFocus
- Do I have to do anything to trigger it the first time? What causes this list of alias's to be built so LaunchBar can find them?
Nope. As soon as you save the rule the first time it should fire and start making and renaming Aliases.
- Then do I need to setup a LaunchBar index rule to find them?
Yes, you'll then want to add the Destination Folder (wherever you put it) as an Index folder for LaunchBar.
Thank yuou !
No problem.
Also, the custom token was a bit tricky for me. Basically, for the last condition:
- Select "Other", then scroll through all of the attributes available in an OmniFocus Project Metadata file to find "Title"
- Set it to "matches"
- Click on the "dot" for a Custom token
- Name it "project title"
- Click on "..." next to Anything for the match value
Re: set up direct access to OmniFocus projects

Posted:
Tue Dec 10, 2013 7:09 pm
by ecormany
mlondon, thanks for explaining the bits that i glossed over.
unfortunately, i decided i had to disable this rule after i updated to Mavericks. if you've ever dealt with aliases much in OS X, you know that sometimes it can be quite stupid about including quicklook information in them and making them unnecessarily large (often bigger than the original file). this rule started filling up a folder with 11MB aliases to 16–20K project files. couldn't figure out how to change that behavior, but if i can i'll definitely turn the rule back on.
Re: set up direct access to OmniFocus projects

Posted:
Sun Jan 12, 2014 6:47 pm
by JBB
By any chance has anyone found a way to automatically delete the aliases for projects that have been finished or deleted?
I wondered the same thing myself. I think it would require a rule in the new folder of aliases, that would run from time to time and check for broken aliases, and then delete them. I think an AppleScript could do this as a test condition. Mr. Noodle?
Re: set up direct access to OmniFocus projects

Posted:
Wed Jan 15, 2014 12:07 am
by JBB
I think this will work on the folder with readable project names:
- Code: Select all
if all of the following conditions are met
Kind is Alias
Date Last Matched is not Today
Passes AppleScript [embedded script]
do the following
Move to Trash
The embedded script is:
- Code: Select all
tell application "Finder"
try
set orgFile to original item of file theFile
if orgFile exists then
return false
else
return true
end if
on error
return true
end try
end tell
Re: set up direct access to OmniFocus projects

Posted:
Fri Jan 31, 2014 6:29 am
by kristalharri