Mac Developer Library Developer
Search

 

This manual page is for Mac OS X version 10.9

If you are running a different version of Mac OS X, view the documentation locally:

  • In Terminal, using the man(1) command

Reading manual pages

Manual pages are intended as a quick reference for people who already understand a technology.

  • To learn how the manual is organized or to learn about command syntax, read the manual page for manpages(5).

  • For more information about this technology, look for other documentation in the Apple Developer Library.

  • For general information about writing shell scripts, read Shell Scripting Primer.




mdfind(1)                 BSD General Commands Manual                mdfind(1)

NAME
     mdfind -- finds files matching a given query

SYNOPSIS
     mdfind [-live] [-count] [-onlyin directory] [-name fileName] query

DESCRIPTION
     The mdfind command consults the central metadata store and returns a list of files that match the given
     metadata query. The query can be a string or a query expression.

     The following options are available:

     -0          Prints an ASCII NUL character after each result path.  This is useful when used in conjunc-tion conjunction
                 tion with xargs -0.

     -live       Causes the mdfind command to provide live-updates to the number of files matching the
                 query.  When an update causes the query results to change the number of matches is updated.
                 The find can be cancelled by typing ctrl-C.

     -count      Causes the mdfind command to output the total number of matches, instead of the path to the
                 matching items.

     -onlyin dir
                 Limit the scope of the search to the directory specified.

     -name fileName
                 Searches for matching file names only.

     -literal    Force the provided query string to be taken as a literal query string, without interpreta-tion. interpretation.
                 tion.

     -interpret  Force the provided query string to be interpreted as if the user had typed the string into
                 the Spotlight menu.  For example, the string "search" would produce the following query
                 string:
                       (* = search* cdw || kMDItemTextContent = search* cdw)

EXAMPLES
     The following examples are shown as given to the shell.

     This returns all files with any metadata attribute value matching the string "image":

           mdfind image

     This returns all files that contain "MyFavoriteAuthor" in the kMDItemAuthor metadata attribute:

           mdfind "kMDItemAuthor == '*MyFavoriteAuthor*'"

     This returns all files with any metadata attribute value matching the string "skateboard".  The find
     continues to run after gathering the initial results, providing a count of the number of files that
     match the query.

           mdfind -live skateboard

     To get a list of the available attributes for use in constructing queries, see mdimport(1),
     particularly the -X switch.

SEE ALSO
     mdimport(1), mdls(1), mdutil(1), xargs(1)

Mac OS X                         June 10, 2004                        Mac OS X

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors
Report errors in the content of this documentation with the feedback links below.
Bug reports
Report bugs in the functionality of the described tool or API through Bug Reporter.
Formatting problems
Report formatting mistakes in the online version of these pages with the feedback links below.

Feedback