Giter Site home page Giter Site logo

node-mdfind's Introduction

node-mdfind

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

Installation

npm install mdfind

Example

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: [ '[email protected]' ] }
{ kMDItemPath: '/Users/myuser/Library/Application Support/AddressBook/Sources/some_guid/Metadata/some_guid2:ABPerson.abcdp',
  kMDItemDisplayName: 'Bill Gates',
  kMDItemEmailAddresses: [ '[email protected]' ] }
**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.

node-mdfind's People

Contributors

brandonhorst avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.