Jump to content

Excluding Folders


Recommended Posts

How can I exclude folders from my search results? I have Parallels installed, which created a Windows Application folder and every time I launch an application. For example Google Chrome I get two options, the mac version and the version installed in Parallels. 

 

I know that Alfred is smart enough to show the mac version first but it would be nice to avoid search results from specific folders.

Link to post

Neither of these methods is working for me. I added the comment, and added the folder containing the applications I don't want to show up in my search results to System Preferences > Spotlight > Privacy  but I'm still seeing them. Is there anything else I can do?

 

 Screen%20Shot%202013-03-23%20at%206.12.4

Link to post

I just realized that Spotlight no longer shows results for the Windows Applications folder, but why does Alfred keep showing me those results? Is there a Spolight setting within Alfred I need to look at?

 

Have you tried reloading the Alfred app cache? Check out the Advanced tab in Alfred's preferences to clear the cache. You could also try dragging the Applications folder in the Privacy section, waiting a moment, and then pulling it back out. That ill cause OSX to reindex the Applications folder.

Link to post
  • 1 year later...

Thanks for the advice all. The alfred:ignore tip didn't work for me, although maybe I just needed to wait longer for the cache to reload. Whatever the case, the spotlight privacy settings worked. My next question is: is it possible to tell alfred to ignore a folder in general search, but to not ignore when using a specific keyword? I have many articles on my computer that I don't want to sift through every time I use alfred, but I want to be able to search through them with a keyword "article." Does anyone have any ideas?

Link to post

Thanks for the advice all. The alfred:ignore tip didn't work for me, although maybe I just needed to wait longer for the cache to reload. Whatever the case, the spotlight privacy settings worked. My next question is: is it possible to tell alfred to ignore a folder in general search, but to not ignore when using a specific keyword? I have many articles on my computer that I don't want to sift through every time I use alfred, but I want to be able to search through them with a keyword "article." Does anyone have any ideas?

 

Is it a folder or the contents within the folder that you aren't wanting to see in default results? The reason I ask is, if it's the contents, what I would more suggest would be to turn off some of the additional items in the Default Results section of Alfred's prefs and have a workflow file filter to search just that folder and its contents. That way you don't get a bunch of random stuff in the default results and can then have keywords when you want to specifically target certain areas.

 

For instance, I only have Apps, Contacts, and Preferences shown in the default results, no folders. If I want to search folders, I have a file filter with the keyword set to a comma, that searches and shows ONLY folder results. Or if I had a workflow that was all work related content, I could create a file filter that would search ONLY that folder and it's contents.

Link to post

Is it a folder or the contents within the folder that you aren't wanting to see in default results? The reason I ask is, if it's the contents, what I would more suggest would be to turn off some of the additional items in the Default Results section of Alfred's prefs and have a workflow file filter to search just that folder and its contents. That way you don't get a bunch of random stuff in the default results and can then have keywords when you want to specifically target certain areas.

 

For instance, I only have Apps, Contacts, and Preferences shown in the default results, no folders. If I want to search folders, I have a file filter with the keyword set to a comma, that searches and shows ONLY folder results. Or if I had a workflow that was all work related content, I could create a file filter that would search ONLY that folder and it's contents.

 

Sorry, I should have been more clear. It is the contents of the folder that I am interested in filtering. I thought of turning off all PDFs in the default results, but ideally I would be able to see some PDFs in the default results, just not the ones in one folder. This might not be possible, but my goal is to blacklist a particular folder (rather than a particular file type) from only the default results.

Link to post
  • 3 years later...

Sorry for reviving an old thread but this is the first Google result on the matter.

 

Would be awesome if there was a way to define a dynamic ignore. For example I'd like to ignore all node_modules folders which are created on every new JS project.

 

AFAIK there is not really a way to do that in Spotlight either, but it would be awesome if Alfred could solve this.

Link to post
3 hours ago, pier said:

AFAIK there is not really a way to do that in Spotlight either

 

That's basically why it's impossible to do with Alfred, too.

 

Alfred uses the same metadata index and API as Spotlight, so suffers from many of the same limitations, including the "whitelist-only" approach, which is inherent to the API.

 

So for technical reasons, adding a blacklisting layer to Alfred would have a very significant impact on performance.

 

A blacklist has been requested many times, but the Alfred team has expressed reluctance for the above reason.

 

It sucks especially for folks with Node projects, as node_modules is basically Alfred's kryptonite. A Node project is effectively a worst-case scenario for the Spotlight/Alfred model.

 

Link to post
3 hours ago, dfay said:

A Hazel rule to add the tag to any folder named node_modules & its contents should be trivial to set up.

 

It's trivial to set up, but not necessarily a great idea.

 

There can be many tens of thousands of files in node_modules, and Hazel's help specifically warns against rules that would cause it to visit every file in such a large tree.

 

I think you'd be better off with a script that you can run as needed rather than having Hazel check every single file in node_modules every time something changes.

Link to post
4 hours ago, deanishe said:

I think you'd be better off with a script that you can run as needed rather than having Hazel check every single file in node_modules every time something changes.

 

Would adding the alfred:ignore tag to a folder make Alfred ignore all the files and subfolders too?

Edited by pier
Link to post
8 minutes ago, pier said:

Would adding the alfred:ignore tag to a folder make Alfred ignore all the files and subfolders too?

 

No. If it did, this would be easy to do…

 

The alfred:ignore tag only applies to the folder it's set on, not its contents.

 

Hazel, as @dfay recommended, is a great fit for the task of tagging all the files in general. But you have to be careful using Hazel with large directory trees and recursive rules (which you'd probably need in this case). You don't want Hazel checking 20,000+ files every time something changes in node_modules. Hazel's UI also isn't very good with large numbers of folders.

 

I think the "right" solution would be a post-install hook that tags just the package that changed/was added.

 

Link to post
  • 1 year later...
On 1/28/2018 at 5:30 PM, deanishe said:

 

That's basically why it's impossible to do with Alfred, too.

 

Alfred uses the same metadata index and API as Spotlight, so suffers from many of the same limitations, including the "whitelist-only" approach, which is inherent to the API.

 

So for technical reasons, adding a blacklisting layer to Alfred would have a very significant impact on performance.

 

A blacklist has been requested many times, but the Alfred team has expressed reluctance for the above reason.

 

It sucks especially for folks with Node projects, as node_modules is basically Alfred's kryptonite. A Node project is effectively a worst-case scenario for the Spotlight/Alfred model.

 

 

Would a regex filter option be an acceptable compromise there? In our case, we want to omit any file with `node_modules` in the file path. Doesn't seem like that would add much overhead

Link to post
12 hours ago, BrandonS said:

Would a regex filter option be an acceptable compromise there?

 

As I understand it, it's not the actual filtering that's an issue, it's retrieving the metadata for the search results from the metadata API that are required to do the filtering in the first place.

 

Say, for example, you search for "index.js", the API will return (hundreds of) thousands of results if you have some Node projects. The API only returns "handles" for the results, which is very fast. The application (Alfred) then has to separately request the actual metadata for each result it's interested in. This is the slow bit, so Alfred tries to retrieve the metadata for as few files as possible.

 

So excluding node_modules from a search of your Node projects (which really is a worst-case-scenario for a search system set up this way) would mean Alfred has to fully load many, many thousands of results just to throw 95% or more of them away. Which would be terribly slow in any case.

 

A better solution (for the Node case, at least) would be to write yourself a workflow based on ripgrep or some other gitignore-aware search tool. The best solution would probably be yarn 2, as @Paul Razvan Berg suggested above. The whole Node idea of plopping all your app's dependencies in the project folder is okay for deployment, but a silly way to develop (given the stupendous number of dependencies that typical Node apps have).

Edited by deanishe
Link to post
  • 5 months later...
  • 3 months later...
On 5/5/2020 at 4:15 AM, possertive said:

Has there been a solution to exclude node_modules and/or specific named folders from being indexed? Not just filtering as denishe mentioned?

 

 

Although not perfect, I've written a small helper to add all `node_modules` folders to Spotlight ignore list.

https://github.com/Strajk/setup/blob/master/programs/prevent-spotlight-from-indexing-node-modules.js

 

(But I'm still hoping for better solution)

Link to post
  • 2 months later...
On 5/5/2020 at 4:15 AM, possertive said:

Has there been a solution to exclude node_modules and/or specific named folders from being indexed? Not just filtering as denishe mentioned?

 

My workaround is to add the project folders to the Privacy tab in Spotlight prefs. It's not perfect but I rarely search for source code files with Alfred or Spotlight. 

Of course you could also add all folders named node_module but that would be harder to back track. For this approach, do a Finder search and just drag n drop.

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...