Anyone know the Spotlight query syntax for "only" to limit scope to a folder?

Discussion in 'macOS' started by sclough, May 17, 2010.

  1. sclough macrumors regular

    May 23, 2008
    Kansas City, MO
    I'm trying to see if there is a way in a spotlight query to limit the scope to a particular folder. I have found many of the options such as "kind:app" and "date:today" but I can't find a syntax to limit the search to a folder. If you run the query from the command line using mdfind, you can use the argument onlyin but I can't find an equivalent for the regular query syntax used by the gui.

    I do know how to limit the search using finder, but I'm trying to find the syntax that does this because I'm playing around with using Spotlight as a catalog for Quicksilver.
  2. joshellis625 macrumors 6502


    Feb 16, 2008
    open the folder you want to search and then use the spotlight box in that folder's window.
  3. -aggie- macrumors P6


    Jun 19, 2009
    Where bunnies are welcome.
    He wants to do this programatically.

    See this page:

    I believe you can use the schema.strings file in:


    and see this string:


    It hasn’t been defined as a user string, so if you add it after line 312 of that file, I would suppose it will work.

    Something like:

    "kMDItemFSNodeCount.Description" = “Folder”;

    and then use the syntax you used for the other searches. You can try it at least.

Share This Page