Skip to main content

Spotlight

Exclude folders from index

It seems like .metadata_never_index method does not work anymore, since Mojave.

However *.noindex and symlink aren't indexed by mds (the backend of Spotlight).

For example rename all node_modules to node_modules.noindex and create a symlink node_modules -> node_modules.noindex

find /path/to/projects -type d \( -path '*node_modules/*' -o -path '*node_module.noindex/*' \) \
    -prune -o -type d -name 'node_modules' -exec mv '{}' '{}.noindex' \; \
    -exec ln -s '{}.noindex' '{}' \;