mdls

mdls from your node module

mdls

OSX's mdls from node.

A thin wrapper around mdls.

You give it a path, it runs mdls and calls a callback with the result.

Install:

npm install --save mdls

Usage:

var mdls = require('mdls')
 
mdls('./index.js', function(err, data) {
  console.log(err, data)
})

If all goes well, this will log:

{ ContentCreationDate: Sat May 17 2014 14:32:53 GMT-0700 (PDT),
  ContentModificationDate: Sat May 17 2014 15:01:52 GMT-0700 (PDT),
  ContentType: 'com.netscape.javascript-source',
  ContentTypeTree:
   [ 'com.netscape.javascript-source',
     'public.source-code',
     'public.plain-text',
     'public.text',
     'public.data',
     'public.item',
     'public.content',
     'public.executable' ],
  DateAdded: Sat May 17 2014 14:32:53 GMT-0700 (PDT),
  DisplayName: 'index.js',
  FSContentChangeDate: Sat May 17 2014 15:01:52 GMT-0700 (PDT),
  FSCreationDate: Sat May 17 2014 14:32:53 GMT-0700 (PDT),
  FSCreatorCode: '',
  FSFinderFlags: 0,
  FSHasCustomIcon: 0,
  FSInvisible: 0,
  FSIsExtensionHidden: 0,
  FSIsStationery: 0,
  FSLabel: 0,
  FSName: 'index.js',
  FSNodeCount: 1554,
  FSOwnerGroupID: 20,
  FSOwnerUserID: 501,
  FSSize: 1554,
  FSTypeCode: '',
  Kind: 'JavaScript',
  LogicalSize: 1554,
  PhysicalSize: 4096 }

Each date above is a javascript date object. You can get the unix timestamp out with the .getTime method of each object.

Note that running mdls the command line utility would have returned:

kMDItemContentCreationDate     = 2014-05-17 21:32:53 +0000
kMDItemContentModificationDate = 2014-05-17 22:01:52 +0000
kMDItemContentType             = "com.netscape.javascript-source"
kMDItemContentTypeTree         = (
    "com.netscape.javascript-source",
    "public.source-code",
    "public.plain-text",
    "public.text",
    "public.data",
    "public.item",
    "public.content",
    "public.executable"
)
kMDItemDateAdded               = 2014-05-17 21:32:53 +0000
kMDItemDisplayName             = "index.js"
kMDItemFSContentChangeDate     = 2014-05-17 22:01:52 +0000
kMDItemFSCreationDate          = 2014-05-17 21:32:53 +0000
kMDItemFSCreatorCode           = ""
kMDItemFSFinderFlags           = 0
kMDItemFSHasCustomIcon         = 0
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 0
kMDItemFSIsStationery          = 0
kMDItemFSLabel                 = 0
kMDItemFSName                  = "index.js"
kMDItemFSNodeCount             = 1554
kMDItemFSOwnerGroupID          = 20
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = 1554
kMDItemFSTypeCode              = ""
kMDItemKind                    = "JavaScript"
kMDItemLogicalSize             = 1554
kMDItemPhysicalSize            = 4096