Thursday, April 6, 2017

Excluding Files From Spotlight and Time Machine

user495470 (via Rich Trouton):

  • Create a file named .metadata_never_index inside a folder.
  • Rename folders or files so that they end with .noindex.
  • If you only want to hide files from the GUI, move them to a system folder like ~/Library/.
  • Move the files to a folder that starts with a period like ~/.fontconfig/. It doesn't remove them from mdfind queries like mdfind 'kMDItemFSName=*' -onlyin ~/.fontconfig/ though.

The .metadata_never_index trick was new to me. Excluding temporary files, or other files that you know you won’t need to search, from Spotlight can really speed things up.

As for Time Machine, I could not find it documented, but it seems to exclude folders with the .nobackup extension. There are also APIs such as CSBackupSetItemExcluded() and NSURLIsExcludedFromBackupKey for excluding items, and you can use tmutil isexcluded to check whether a particular item is excluded.

Update (2017-04-06): Thomas:

I have another one: disable fsevents by creating a “.fseventsd/no_log” file at the root of the volume. Haven’t tested this in a while though.

1 Comment RSS · Twitter


Jean-Daniel

For time machine, unfortunately, it looks like tmutil is broken.

I used it to 'addexclusion' of folders I don't want to backup, but for some times now, it fails at such task by telling me it can't exclude an items without an absolute path.

By default, it should use extended attribute and not path exclusion, but the behavior changed some times ago, and there is no flag to revert the behavior.

Leave a Comment