Alfred is a great productivity enhancer for the Mac. I’ve been using it a lot in recent months.
A useful recent addition to the Alfred Powerpack is the ability to specify search filters to restrict the files that are returned by a search.
Search filters are useful, but are limited to the metadata in the Spotlight index that Alfred uses.
I wanted to write a filter to search easily among my project folders.
My projects are all located in a
Projects directory of your home folder.
It’s easy to make a filter that searches
~/Projects for all folders.
Unfortunately, this filter includes the many sub-folders, which is not what I usually want.
There appears to be no way to use default Spotlight metadata to restrict the search to just the top-level folders in
A workaround that I’ve just started using to achieve this effect is to use Finder labels to tag the project folders.
For example, I use the Finder to label all of the folders in
~/Projects with the Green label.
mdls command on one of those folders shows the
kMDItemFSLabel metadata field and associated value.
kMDItemFSLabel = 2
With the folders tagged in this way, you can add the
kMDItemFSLabel metadata field and value to your Alfred search filter so that only those labelled folders are found.
I have a filter with keyword
proj whose scope is restricted to
The file types are set to
Advanced tab, I have the two usual fields
kMDItemFinderComment, so the search looks at the name and comment fields, plus
kMDItemFSLabel with value 2.
proj search only considers the top-level project folders and will ignore all of the sub-folders.
A variant of this scheme that I also use is to label some of the project folders with a different colour when I am actively working on them.
now search filter allows me to quickly search for my current projects.
This scheme allows me to easily switch focus by just changing the folder labels.
Alfred always knows which folders are the most important, so I can get to them quickly.