A bit more digging gives me this following stackexchange question: https://apple.stackexchange.com/questions/87090/how-to-programatically-add-folder-to-spotlight-do-not-index <https://apple.stackexchange.com/questions/87090/how-to-programatically-add-folder-to-spotlight-do-not-index>
On 12.0.1 I do confirm that the folder exclusions indicated in the System Preferences are there: /System/Volumes/Data/.Spotlight-V100/VolumeConfiguration.plist On the other hand `sudo mdutil -P /` returns a different file, while `sudo mdutil -P /Volumes/Macintosh\ HD` returns nothing. Additionally, `sudo mdutil -L /Volumes/Macintosh\ HD` returns `Spotlight directory not found at root: /Volumes/Macintosh HD`, while `sudo mdutil -L /` returns: /private/var/db/Spotlight-V100/BootVolume: drwx------ 2 0 0 64 Aug 25 2021 16:27 Store-V2 -rw------- 1 0 0 4316 Aug 25 2021 16:28 VolumeConfiguration.plist /private/var/db/Spotlight-V100/BootVolume/Store-V2: That's as good as I have for now. > On 17 Nov, 2021, at 14:16, André-John Mas <andrejohn....@gmail.com> wrote: > > When looking at "System Preferences -> Spotlight -> Privacy", you can > configure exclusions by folder. > > I had a look at the mdutil command and no reference to folders or paths is > mentioned, when looking from macOS 12.0.1: > > Usage: mdutil -pEsa -i (on|off) -d volume ... > mdutil -t {volume-path | deviceid} fileid > Utility to manage Spotlight indexes. > -i (on|off) Turn indexing on or off. > -d Disable Spotlight activity for volume (re-enable using > -i on). > -E Erase and rebuild index. > -s Print indexing status. > -a Apply command to all stores on all volumes. > -t Resolve files from file id with an optional volume path > or device id. > -p Publish metadata. > -V vol Apply command to all stores on the specified volume. > -v Display verbose information. > -r plugins Ask the server to reimport files for UTIs claimed by the > listed plugin. > -L volume-path List the directory contents of the Spotlight index on > the specified volume. > -P volume-path Dump the VolumeConfig.plist for the specified volume. > -X volume-path Remove the Spotlight index directory on the specified > volume. Does not disable indexing. > Spotlight will reevaluate volume when it is unmounted > and remounted, the > machine is rebooted, or an explicit index command such > as 'mdutil -i' or 'mdutil -E' is > run for the volume. > NOTE: Run as owner for network homes, otherwise run as root. > > I am starting to wonder if there is another command we should be using, in > place of mdutil? > > >> On 17 Nov, 2021, at 13:31, Peter Hancock <hanc...@fastmail.fm >> <mailto:hanc...@fastmail.fm>> wrote: >> >> On 17/11/2021 15:46, Chris Jones wrote: >>> Some users might find it useful, and the exact volume to exclude >>> depends on the details of the users installation, which would be >>> difficult to automate. So I think its fine to just leave it to be >>> done by hand by those that wish to. >>> On 17/11/2021 3:09 pm, André-John Mas wrote: >>>> Just wondering whether it would make sense for MacPorts to auto >>>> exclude that folder? Does spotlight even provide an API or command >>>> that would allow MacPorts to do that?>> >> >> André-John Mas mentions folders (directories?), while Chris Jones mentions >> volumes >> (mounted filesystems?). >> >> On Catalina, for me the command "sudo mdutil -i off /opt/local/var/macports " >> evokes: >> [ >> Password: >> /System/Volumes/Data/opt/local/var/macports: >> Error: invalid operation. >> Error: unknown indexing state. >> ] >> >> Trying to drag that directory into the appropriate System Preferences >> "privacy" pane, >> accomplishes nothing. It doesn't appear on the list. >> >> My man page for mdutil seems to speak only about volumes. A bit of googling >> suggests >> that though there *may* have been a time when you could exclude various >> directories >> from spotlight indexing, by one trick or another, those days are gone. >> >> Am I wrong? >> >> I hope so. I'm getting pretty dyspeptic about how much of my computer seems >> to be >> taken over by Spotlight and it's various underlings/minions. >> >> (Eg, It/they seem(s) to spend a large chunk of resources on creating >> tens/hundreds of thousands >> of empty directories deep under /private/var/folders, to no apparent >> purpose.) >> >> >> >