> On Nov 6, 2014, at 7:45 PMaxieie, steve harley <[email protected]> wrote:
> 
> on 2014-11-06 18:50 Michael wrote
>> mdfind -name Xcode
>> 
>> returns every file with "Xcode" anywhere in the filename. Case insensitive.
>> 
>> What's the proper way to use mdfind?
> 
> mdfind kMDItemFSName == XCode.app

Yep, that is the way. mdfind has an entire LANGUAGE practically of options. 
They are not documented in the man page, but you can do mdls on a file and 
every bit of metadata listed is something you can use mdfind to search for.

# mdls James\ and\ Maxie-med.jpg 
kMDItemAcquisitionMake         = "Brother"
kMDItemAcquisitionModel        = "MFC-7860DW"
kMDItemBitsPerSample           = 32
kMDItemColorSpace              = "RGB"
kMDItemContentCreationDate     = 2014-08-20 22:35:24 +0000
kMDItemContentModificationDate = 2014-08-20 22:35:24 +0000
kMDItemContentType             = "public.jpeg"
kMDItemContentTypeTree         = (
    "public.jpeg",
    "public.image",
    "public.data",
    "public.item",
    "public.content"
)
kMDItemCreator                 = "Pixelmator 3.2"
kMDItemDateAdded               = 2014-11-04 06:07:40 +0000
kMDItemDisplayName             = "James and Maxie-med.jpg"
kMDItemFSContentChangeDate     = 2014-08-20 22:35:24 +0000
kMDItemFSCreationDate          = 2014-08-20 22:35:24 +0000
kMDItemFSCreatorCode           = ""
kMDItemFSFinderFlags           = 0
kMDItemFSHasCustomIcon         = (null)
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 0
kMDItemFSIsStationery          = (null)
kMDItemFSLabel                 = 0
kMDItemFSName                  = "James and Maxie-med.jpg"
kMDItemFSNodeCount             = (null)
kMDItemFSOwnerGroupID          = 20
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = 499724
kMDItemFSTypeCode              = ""
kMDItemHasAlphaChannel         = 0
kMDItemKind                    = "JPEG image"
kMDItemLogicalSize             = 499724
kMDItemOrientation             = 0
kMDItemPhysicalSize            = 507904
kMDItemPixelCount              = 1475280
kMDItemPixelHeight             = 1080
kMDItemPixelWidth              = 1366
kMDItemProfileName             = "Brother sRGB Scanner"
kMDItemResolutionHeightDPI     = 600
kMDItemResolutionWidthDPI      = 600

If I do mdfind kMDItemAcquisitionMake == Brother I will get everything that was 
scanned on my Borther AIO, for example.

You can do complicated boolean searches with different terms. For example, I 
could search for all thefiles that came from my AIO and are less than 600 
pixels wide:

mdfind 'kMDItemAcquisitionMake == Brother && kMDItemPixelWidth < 600’

just as an example.

the one thing you CANNOT search for in mdfind is the path of a file though. You 
can’t say find all the files of type PDF that are in any folder who’s name 
contains ‘tax’.

Though I suppose you can do:

mdfind kind:pdf | grep -i tax

-- 
He'd never asked for an exciting life. What he really liked, what he
sought on every occasion, was boredom. The trouble was that boredom
tended to explode in your face. Just when he thought he'd found it he'd
be suddenly involved in what he supposed other people - thoughtless,
feckless people - would call an adventure. And he'd be forced to visit
many strange lands and meet exotic and colourful people, although not
for very long because usually he'd be running. He'd seen the creation of
the universe, although not from a good seat, and had visited Hell and
the afterlife. He'd been captured, imprisoned, rescued, lost and
marooned. Sometimes it had all happened on the same day.

_______________________________________________
MacOSX-talk mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/macosx-talk

Reply via email to