Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Is it possible to prevent spotlight from indexing all folders with a specific name?

As a developer I encounter folders like "node modules" that should never be indexed. I don't want to add this folder to the non-indexed list in system-preferences > spotlight > privacy for every single project manually and have to manage that. My current solution is to prevent Spotlight from indexing everything inside my development folder.


Is there a way to tell spotlight to not index any folder with a specific name like "node-modules"? Perhaps a terminal command or with Applescript (does Applescript even exist anymore?)

MacBook

Posted on Aug 10, 2019 8:47 AM

Reply
2 replies

Aug 10, 2019 12:03 PM in response to Ahab the Eskimo

You’ll have to write some code to do that. Use the file system events for the creation of one of those entries, and have that add the Spotlight exclusion. Probably also to remove the exclusion when the files are deleted.


Seems like a whole lot of work for not much benefit, though.


As for AppleScript, it’s mostly still around. Wouldn’t be my choice here, and isn’t particularly applicable here.


Is it possible to prevent spotlight from indexing all folders with a specific name?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.