Forcing Spotlight to index dot directories (& contents thereof)

I commonly need to find files hidden in dot directories of my computer. I am given to understand that Spotlight does not index hidden directories by default. I'd like to know if there is a way to force indexing of the +contents of hidden directories.+ According to an old doc I found online, the mdimport -f option used to this, but -f is obsoleted in Leopard. Is there another way?

If not, why? It's inconvenient enough to have to manually do it. It's atrocious if there's no way at all.

Mac Pro 8-core | Blackbook 2.16ghz, Mac OS X (10.5.6)

Posted on Jul 21, 2009 9:32 AM

Reply
9 replies

Jul 21, 2009 2:44 PM in response to Francine Schwieder

Francine Schwieder wrote:
Actually you can search things that are simply hidden, such as /private. Just go there using the "Go To Folder" item in the Finder's Go menu, or use the open command in Terminal, or make aliases to all the ones you want to quickly open and double click the alias (this is what I have done). So open /private, and hit Command-F, then click "private" in the Search window toolbar, and set your seach. For instance, if I do that and select Name:contains:make, I instantly get two files listed


Thanks for the suggestion, Francine, but frankly, if I already know what folder it's in, and already have to type in the path to that folder, then I have no reason to be searching for it. At that point I would simply tab-autocomplete the name of the file and directly open it.

Jul 21, 2009 10:04 AM in response to mkramer

Try doing a Find from a Finder window and in the pulldown menu that says "Kind", select "System Files" and set the adjacent pulldown to "are included". Unless something's different about my system, you should find that you can now search in the hidden directories.

An alternative is the freeware EasyFind which can also be set to show invisible files and directories.

Hope this helps.

Jul 21, 2009 11:33 AM in response to varjak paw

I did try System Files, but it doesn't find it with those. The System files (~/Library, /Library, /System/, maybe others) are not actually hidden directories, they are simply specially omitted directories. When system files are enabled, Spotlight still doesn't index /private/, /usr/ and /bin/, which are hidden. In fact, I don't wish to index those. I want to index my source code repositories, which have lots of hidden files.

Thanks for the link to EasyFind, but if it comes down to it I already have hooks into the Unix find and globbing utilities straight from Path Finder. What I want is to harness the great power of Spotlight on-the-fly indexing to find these things quickly from a unified interface, and in saved searches.

Jul 21, 2009 2:04 PM in response to mkramer

Actually you can search things that are simply hidden, such as /private. Just go there using the "Go To Folder" item in the Finder's Go menu, or use the open command in Terminal, or make aliases to all the ones you want to quickly open and double click the alias (this is what I have done). So open /private, and hit Command-F, then click "private" in the Search window toolbar, and set your seach. For instance, if I do that and select Name:contains:make, I instantly get two files listed

/private/var/yp/Makefile.main
/private/var/yp/Makefile.yp

The problem is that searching for content in pretty much any of those places is basically fruitless, because all, or nearly all, the files are things that do not have mdimporters (and why a perfectly ordinary plain text file isn't handled, just because it doesn't have a .txt extension, when Finder itself can identify the file as plain text, well, I'm at a loss to understand that). Whether the files would be indexed at to content if there were an mdimporter for them, I just don't know.

You can do the same sort of thing with dot folders: open it by "Go to" or with an open command, then hit Command-F to bring up the search window. But again you will be able to search by name, even date, but the content searches won't work. In this case I happen to know that the items are not actually handled by their mdimporters, even when there is an mdimporter. The only information available to spotlight is the basic file system information, name, extension, size and dates.
Francine

User uploaded file
Francine
Schwieder

Jul 21, 2009 2:29 PM in response to V.K.

this works but only if you open the folder where you are searching first.


I thought that is what I said. If I wasn't clear I'm sorry. Yes, you need to open the folder then do the search. I also tried a further experiment with a dot folder. I used this command to see if I could get the files in a sub-folder processed:

NoobiX:~ francine$ mdimport /Users/francine/.thumbnails/normal/

It seemed to work: when I did an mdls on one of the pngs I got more than just basic file system information I had seen before running mdimport. Indeed, got the pixel height and width, orientation, type tree, color space, and so on. However, when I went to do a Spotlight search none of those content items brought up any results. Disappointing!
Francine

User uploaded file
Francine
Schwieder

Jul 21, 2009 2:42 PM in response to Francine Schwieder

mdimport will happily index unhidden folders that are children of hidden folders. RTC:

cd ~; mkdir -p .hidden/unhidden; cd .hidden; touch hiddenTest; cd unhidden; touch unhiddenTest; mdimport -V ~/.hidden/; mdimport -V ~/.hidden/unhidden/;

Total processing time spent in importer plug-ins: 0.000000 seconds for 0 files
Top 0 most expensive files for importer plug-ins:
Total processing time spent in importer plug-ins: 0.045826 seconds for 2 files
Top 2 most expensive files for importer plug-ins:
1 /Users/masonkramer/.hidden/unhidden: 0.044124 seconds
2 /Users/masonkramer/.hidden/unhidden/unhiddenTest: 0.001702 seconds

Should I file a bug on this? Tearing one's hair out trying to spotlight a file _that you know is there_ in a hidden folder just seems like malevolent way to waste time.

Jul 21, 2009 2:45 PM in response to Francine Schwieder

Francine Schwieder wrote:
this works but only if you open the folder where you are searching first.


I thought that is what I said. If I wasn't clear I'm sorry.

no, you were quite clear - I didn't mean to imply you weren't. I was just stressing that with your method one has to open the exact folder you are searching first. that's a VERY serious limitation IMO and I wish there was a way around it but AFAIK, there isn't.

Yes, you need to open the folder then do the search. I also tried a further experiment with a dot folder. I used this command to see if I could get the files in a sub-folder processed:

NoobiX:~ francine$ mdimport /Users/francine/.thumbnails/normal/

It seemed to work: when I did an mdls on one of the pngs I got more than just basic file system information I had seen before running mdimport. Indeed, got the pixel height and width, orientation, type tree, color space, and so on. However, when I went to do a Spotlight search none of those content items brought up any results. Disappointing!

exactly! I usually really hate recommending spotlight alternatives like EasyFind but in this case I don't see any other option. unless someone knows how to coerce spotlight to do this?
Francine

User uploaded file
Francine
Schwieder

Jul 21, 2009 8:19 PM in response to mkramer

Should I file a bug on this?


By all means! It is absurd that the mdimporter will work, that mdls will return the results, but that there is no way to get Spotlight to look at 'em. But then I have been VERY disappointed with the "improved" Spotlight. I could get Tiger's version to work better for everything I wanted to do. Sometimes it was a bit messy to get there, but you COULD get there. Leopard's version has been crippled in all sorts of unbelievable ways.
Francine

User uploaded file
Francine
Schwieder

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Forcing Spotlight to index dot directories (& contents thereof)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.