MacMost Q&A Forum • View All Forum QuestionsAsk a Question

How Do I Use Spotlight To Find Any File On My Mac, If I Know the File Name?

I needed to find a file with file name “tsserver.js” on my iMac running macOS Sierra. So the first thing I tried was Spotlight, but it returned no files. Then I launched a search in the Finder, but it also returned no files matching that name.

I was quite sure that I had at least one file with that name on my iMac, so I started a Terminal session and entered the command “mdfind -name tsserver.js” and sure enough, it gave me the locations of several files on my iMac with that name.

So I am puzzled why neither Spotlight nor the Finder enabled me to find the file. I have done other tests using Spotlight and the Finder and was successfully able to find files using either of those utilities. But in the “tsserver.js” example only mdfind worked.

Is it a known feature of Spotlight and the Finder that not all files can be found using those utilities?
Richard Fuhr

Comments: 4 Responses to “How Do I Use Spotlight To Find Any File On My Mac, If I Know the File Name?”

    8 years ago

    So you can search for a filename with the Finder using name:tsserver.js. The "name:" tells Finder search to only look for files with that name, and ignore the content.
    But you also have to set the scope of the search. You don't mention that in the question. When I start a Finder search, I see at the top "Search:" and "This Mac" and then the current folder, with the current folder selected. If I want to search my entire drive, I have to click on This Mac to tell it I want to search everywhere.
    But there are still cases where it may not find things. It isn't going to look in System folders. It isn't going to look inside of "package" files -- like the kind used in photo or video libraries or by some apps or development environments.
    There is also the chance that your drive isn't fully indexed for searching. This would be the case if you just set up a new Mac or just upgraded to a new version of macOS. I've heard of cases where this takes weeks when people start up and shut down their Macs all the time, not giving it any time to do the indexing.
    So, where was the tsserver.js file? Was it in a normal folder in your Documents folder? Inside a package? In the System? Somewhere else?

    Richard Fuhr
    8 years ago

    In this case, the file I was searching for was quite deep in the file system; it was /usr/local/lib/node_modules/typescript/lib/tsserver.js .

    I recently upgraded my macOS to Sierra, so it is possible my computer is still in the process of indexing.

    But also, as Gary mentioned, it is possible that Finder and Spotlight considered the location of this file to be a system folder, in which they don't search at all.,

    8 years ago

    Yes. /usr is a System folder and hidden as well.

    Thomas Tempelmann
    8 years ago

    You could also use the program "Find Any File" - it's specially made for this purpose. See
    Disclaimer: I am the author of said program.

Comments Closed.