For some reason, find returns more results than mdfind.

How can I make sure these files are added to the Spotlight index?

$ find ~/Library -iname "*org.virtualbox.app.VirtualBox*" -prune 2>&1 | grep -av "Permission denied"
/Users/sunknudsen/Library/Saved Application State/org.virtualbox.app.VirtualBox.savedState
/Users/sunknudsen/Library/Saved Application State/org.virtualbox.app.VirtualBoxVM.savedState

$ mdfind -onlyin ~/Library 'kMDItemFSName == "*org.virtualbox.app.VirtualBox*"'

1 Answer 1


Spotlight only processes files it has an importer for the file type and aren't hidden by rule. This folder is excluded by code in Mojave as far as I can tell. In older OS, the Exclusion list was editable in a preference file named VolumeConfiguration.plist and before that, _rules.plist so it was easier for someone technical enough to use the command line to modify an exclusion and make that folder included. I don't think we get this control via the same mechanism now. Apple still lets us exclude arbitrary folders / files, but relaxing their exclusion list to be more inclusive, may not be possible.

If you want to poke at this - the relevant folder is /System/Volumes/Data/.Spotlight-V100

I would use a tool like ag (easily installed with https://brew.sh) to search by name or content rather than using find in the mean time.

If you check mdls for the affected files, you can see the various file types these are and possibly find an app that will claim "indexing" for them.

Here's me reproducing that with a Microsoft preference file:

me@Mac-Pro ~ % mdls ~/Library/Preferences/com.microsoft.autoupdate2.plist
kMDItemFSContentChangeDate = 2020-09-19 20:33:07 +0000
kMDItemFSCreationDate      = 2020-09-19 20:33:07 +0000
kMDItemFSCreatorCode       = ""
kMDItemFSFinderFlags       = 0
kMDItemFSHasCustomIcon     = 0
kMDItemFSInvisible         = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery      = 0
kMDItemFSLabel             = 0
kMDItemFSName              = "com.microsoft.autoupdate2.plist"
kMDItemFSNodeCount         = 965
kMDItemFSOwnerGroupID      = 20
kMDItemFSOwnerUserID       = 501
kMDItemFSSize              = 965
kMDItemFSTypeCode          = ""
me@Mac-Pro ~ % mdfind 'kMDItemFSName == "com.microsoft.autoupdate2.plist"'
me@Mac-Pro ~ % cp -p ~/Library/Preferences/com.microsoft.autoupdate2.plist ~/Desktop
me@Mac-Pro ~ % mdfind 'kMDItemFSName == "com.microsoft.autoupdate2.plist"'          

It's clear Apple has restricted indexing in this directory which is why you can't find preference files in the user Library folder and they show up immediately when copied to your Desktop.

  • 1
    Very helpful, thanks! I copied org.virtualbox.app.VirtualBox.plist to ~/Desktop and mdfind found it... Is there a way to make mdfind find it in ~/Library?
    – sunknudsen
    Commented Sep 19, 2020 at 23:43
  • Would you happen to know how to solve superuser.com/questions/1586989/…?
    – sunknudsen
    Commented Sep 19, 2020 at 23:46
  • @sunknudsen In past OS you could try hand editing preference files. I've updated my answer - you may need a different tool or have to live with find crawling the filesystem.
    – bmike
    Commented Sep 20, 2020 at 16:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .