{"id":17659,"date":"2017-04-06T14:48:00","date_gmt":"2017-04-06T18:48:00","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=17659"},"modified":"2017-04-06T14:59:21","modified_gmt":"2017-04-06T18:59:21","slug":"excluding-files-from-spotlight-and-time-machine","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/04\/06\/excluding-files-from-spotlight-and-time-machine\/","title":{"rendered":"Excluding Files From Spotlight and Time Machine"},"content":{"rendered":"<p><a href=\"http:\/\/apple.stackexchange.com\/questions\/92784\/preventing-spotlight-from-indexing-files-folders\">user495470<\/a> (via <a href=\"https:\/\/twitter.com\/rtrouton\/status\/849776209701609472\">Rich Trouton<\/a>):<\/p>\n<blockquote cite=\"http:\/\/apple.stackexchange.com\/questions\/92784\/preventing-spotlight-from-indexing-files-folders\">\n<ul>\n<li>Create a file named <code>.metadata_never_index<\/code> inside a folder.<\/li>\n<li>Rename folders or files so that they end with <code>.noindex<\/code>.<\/li>\n<li>If you only want to hide files from the GUI, move them to a system folder like <code>~\/Library\/<\/code>.<\/li>\n<li>Move the files to a folder that starts with a period like <code>~\/.fontconfig\/<\/code>. It doesn't remove them from mdfind queries like <code>mdfind 'kMDItemFSName=*' -onlyin ~\/.fontconfig\/<\/code> though.<\/li>\n<\/ul>\n<\/blockquote>\n<p>The <tt>.metadata_never_index<\/tt> trick was new to me. Excluding temporary files, or other files that you know you won&rsquo;t need to search, from Spotlight can really speed things up.<\/p>\n<p>As for Time Machine, I could not find it documented, but it seems to exclude folders with the <tt>.nobackup<\/tt> extension. There are also APIs such as <a href=\"https:\/\/developer.apple.com\/reference\/coreservices\/backup_core\">CSBackupSetItemExcluded()<\/a> and <a href=\"https:\/\/developer.apple.com\/library\/content\/qa\/qa1719\/_index.html\">NSURLIsExcludedFromBackupKey<\/a> for excluding items, and you can use <a href=\"https:\/\/developer.apple.com\/legacy\/library\/documentation\/Darwin\/Reference\/ManPages\/man8\/tmutil.8.html\">tmutil isexcluded<\/a> to check whether a particular item is excluded.<\/p>\n\n<p>Update (2017-04-06): <a href=\"https:\/\/twitter.com\/tclementdev\/status\/850059955625492481\">Thomas<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/tclementdev\/status\/850059955625492481\"><p>I have another one: disable fsevents by creating a &ldquo;.fseventsd\/no_log&rdquo; file at the root of the volume. Haven&rsquo;t tested this in a while though.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[30,1381,1042,216],"class_list":["post-17659","post","type-post","status-publish","format-standard","hentry","category-technology","tag-mac","tag-macos-10-12","tag-spotlight","tag-timemachine"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=17659"}],"version-history":[{"count":3,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17659\/revisions"}],"predecessor-version":[{"id":17662,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17659\/revisions\/17662"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=17659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=17659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=17659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}