Jump to content
elgrayso

Prevent Folder From Being Searched?

Recommended Posts

Is there a way to blacklist certain folders from Alfred search? 

(I don't want Alfred to search for my backup folders, I only want to open originals)

 

I backup many files on my Dropbox. I've noticed that Alfred finds these backup copies in my "find" search and often orders them higher than the originals, sometimes I don't even see the original unless I type out the file name more specifically. This is a problem because I can accidentally make an edit on a "copy" of a file, only to have the original write over this copy in the future. 

 

Share this post


Link to post

Can you exclude your backup folders from Spotlight under the Privacy tab in System Preferences > Spotlight?

This should exclude them from Alfred's results, but also Spotlight's results.

Share this post


Link to post

I need to exclude a glob or regex; not just individual folders.

 

My use case:

 

I have a bunch of Node.js projects in a directory, e.g. /projects.

 

Each of these typically has a node_modules subfolder.

 

I want Alfred and/or Spotlight (I don't "use" Spotlight) to ignore everything in a node_modules folder.  It doesn't seem possible to do this via the Spotlight PrefPane.

 

Alternatively, if Alfred could "prioritize" matches whose path is closer to the root (/ or /projects), that may help.  As it stands, if I type a name of a package (e.g. mocha), I'm not guaranteed to see /projects/mocha; I may get /projects/foo/node_modules/mocha.  There are tens, if not hundreds of results.

 

Any ideas?  I wonder if I can use mdutil or something to blacklist node_modules...

Share this post


Link to post

This seems to work, but not in a "set-it-and-forget-it" way:

sudo find /path/to/projects. -regex .*/node_modules$ -maxdepth 3 | xargs -I {} defaults write /path/to/.Spotlight-V100/VolumeConfiguration.plist Exclusions -array-add '{}'

Share this post


Link to post

I can think of a couple of things you could try.

 

You could create a Launch Agent to watch your projects folder and call a script (or simply the above command) when it changes.

 

You could create an alias for the command to install new modules that installs the modules and then runs your above command.

Share this post


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
×