# mdfind

> Node interface for using Spotlight on Mac (via mdfind)

Latest version **1.0.0** (published 2015-12-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install mdfind
pnpm add mdfind
yarn add mdfind
bun add mdfind
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-12-03 |
| First published | 2015-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | @brandonhorst |
| Maintainers | brandonhorst |
| Keywords | mdfind, spotlight, mac, osx, find, search |

## Links

- npm: https://www.npmjs.com/package/mdfind
- Repository: https://github.com/brandonhorst/node-mdfind
- Issues: https://github.com/brandonhorst/node-mdfind/issues
- npm.io page: https://npm.io/package/mdfind

## Dependencies (3)

- [split](https://npm.io/package/split.md) ^1.0.0
- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [event-stream](https://npm.io/package/event-stream.md) ^3.3.1

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-12-03
- 0.1.0 — 2015-08-05
- 0.0.1 — 2015-04-29

## README

# node-mdfind
Node module for searching OSX Spotlight, using the built-in `mdfind` shell command.

## Installation

```sh
npm install mdfind
```

## Example

```js
var mdfind = require('mdfind')

var res = mdfind({query:'kind:contact', attributes: ['kMDItemDisplayName', 'kMDItemEmailAddresses'], limit: 2})
res.output.on('data', console.log)
res.output.on('end', function () {console.log('**done**')})

/*
{ kMDItemPath: '/Users/myuser/Library/Application Support/AddressBook/Sources/some_guid/Metadata/some_guid1:ABPerson.abcdp',
  kMDItemDisplayName: 'Steve Jobs'
  kMDItemEmailAddresses: [ 'sjobs@apple.com' ] }
{ kMDItemPath: '/Users/myuser/Library/Application Support/AddressBook/Sources/some_guid/Metadata/some_guid2:ABPerson.abcdp',
  kMDItemDisplayName: 'Bill Gates',
  kMDItemEmailAddresses: [ 'billg@microsoft.com' ] }
**done**
*/
```

## Docs

`mdfind` is a single function which accepts a single `options` argument, which can include the following options. These are parallels of the arguments to the `mdfind` command, so check run `man mdfind` to see more details.

- `query`: String
  * This can use operators, wildcards, kind specifiers, and more. See `man mdfind`
- `attributes`: [String]
  * Array of attributes that should be collected for each match. Note that `kMDItemPath` is exported for every file and does not need to be manually specified.
- `limit`: Integer
  * Maximum number of results to return
- `directories`: [String]
  * Array of directory paths to limit the search to
- `names`: [String]
  * Array of filenames (without paths) to limit the search to
- `interpret`: Boolean
  * Force the provided query string to be interpreted as if the user had typed the string into the Spotlight menu.  For example, the `query` string `search` would produce the following query string: `(* = search* cdw || kMDItemTextContent = search* cdw)`

Note that the `live` option, while supported by the shell command, is not currently supported.

The `mdfind` function returns object with two keys:

- `output` this is a Stream that outputs objects. Each file found will be passed to the `data` handler as an object with keys for all specified `attributes`.
- `terminate` is a function which can be called to stop the search at any time.

---
_Source: https://npm.io/package/mdfind · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
