Why does Spotlight omit some files in my search result?

3

I'm trying to use Spotlight (Mountain Lion) to do a recursive search on a bunch of subfolders.

(It's actually the Firefox disk cache, and I'm pecking around for a few images, so I thought this would be more convenient than individually clicking on every file in every subfolder of the disk cache.)

I want to list (actually see a thumbnail of) EVERY file (no search conditions) in all of the subfolders of that particular folder. Can I not just browse to the folder in Finder and enter "*" in Spotlight?

Doing so returned zero results, so I tested Spotlight (again, "*") on a known folder, with six PDFs in it, and it only returned one PDF.

What am I doing wrong?

user285807

Posted 2013-12-31T10:19:04.657

Reputation: 31

Answers

2

A similar discussion was recently posted in the question Which tool is most flexible for searching my whole system, locate or mdfind?. I was unable to get various incantations of mdfind to do searches that locate had no problems with. I suggest using the standard BSD locate facility. Here's what I did to solve your particular case using locate, which was not much:

 $ locate Firefox | grep -i '^/Users/whmcclos.*cache' | head
/Users/whmcclos/Library/Caches/Firefox
/Users/whmcclos/Library/Caches/Firefox/Profiles
/Users/whmcclos/Library/Caches/Firefox/Profiles/cr8059k0.default
/Users/whmcclos/Library/Caches/Firefox/Profiles/cr8059k0.default/.DS_Store
/Users/whmcclos/Library/Caches/Firefox/Profiles/cr8059k0.default/Cache
/Users/whmcclos/Library/Caches/Firefox/Profiles/cr8059k0.default/Cache/0
/Users/whmcclos/Library/Caches/Firefox/Profiles/cr8059k0.default/Cache/0/06
/Users/whmcclos/Library/Caches/Firefox/Profiles/cr8059k0.default/Cache/0/06/ACA5Bd01
/Users/whmcclos/Library/Caches/Firefox/Profiles/cr8059k0.default/Cache/0/06/B30CEd01
/Users/whmcclos/Library/Caches/Firefox/Profiles/cr8059k0.default/Cache/0/09
[...]

but these incantations of mdfind yielded nothing really useful to you:

$ mdfind kMDItemFSName="Firefox"
/Users/whmcclos/Library/Application Support/Firefox
/Users/whmcclos/Desktop/Programs/Internet/Firefox
/Volumes/Time Machine/Time Machine Safe/Users/whmcclos/Documents/Programs/Internet/Firefox

and

$ mdfind -name "Firefox" | grep '^/Users/whmcclos.*cache'

I'm certain it is a permission issue with allowing the meta-data creation facility permission to search and display the proper user login areas, which have restrictive group and user ownership permission; I'm not sure if the user:_spotlight ACL is granting permissions to other tools that only have limited, if any, group and user permissions - I'm still investigating this convoluted issue. I checked, and I haven't restricted Spotlight with any Privacy settings to the areas you are searching.

As you are probably aware, you can check and change the ACL with /bin/ls -le and chmod -a or chmod +a, as in this little sequence that I keep around in my notes file because I use this so infrequently and the syntax isn't intuitive:

# viewing ACL and changing the same:

    $ ls -le
    total 16
    -rw-r--r--+ 1 whmcclos  staff  1918 Dec 18 09:00 README
     0: user:_spotlight inherited allow read,execute,readattr,readextattr,readsecurity
    -rw-r--r--+ 1 whmcclos  staff   192 Nov 15 12:30 try.pl
     0: user:_spotlight inherited allow read,execute,readattr,readextattr,readsecurity

    $ chmod -a "user:_spotlight allow read,execute,readattr,readextattr,readsecurity" README

    $ ls -le
    total 16
    -rw-r--r--  1 whmcclos  staff  1918 Dec 18 09:00 README
    -rw-r--r--+ 1 whmcclos  staff   192 Nov 15 12:30 try.pl
     0: user:_spotlight inherited allow read,execute,readattr,readextattr,readsecurity

    $ chmod +ai "user:_spotlight allow read,execute,readattr,readextattr,readsecurity" README

    $ ls -le
    total 16
    -rw-r--r--+ 1 whmcclos  staff  1918 Dec 18 09:00 README
     0: user:_spotlight inherited allow read,execute,readattr,readextattr,readsecurity
    -rw-r--r--+ 1 whmcclos  staff   192 Nov 15 12:30 try.pl
     0: user:_spotlight inherited allow read,execute,readattr,readextattr,readsecurity

Towards that end, and towards understanding how to fine tune locate and how it searches the FS to populate its internal /var/db/locate.database, we've come up with a fairly portable group permission membership utility if you'd care to explore if changing various file user and group permissions will add visibility to Spotlights search results. I haven't had a chance to try that, yet. Quite frankly, I've been very happy since I re-enabled locate in OSX.

Billy McCloskey

Posted 2013-12-31T10:19:04.657

Reputation: 1 487

1

Doing a Spotlight search for * won't list all the items.

The best you can do in Finder is enter nothing in the search box, and change the search criteria to look for files with a modification date after an arbitrary old date.

Last modified date is after 01/01/1970

grg

Posted 2013-12-31T10:19:04.657

Reputation: 1 499