0xFE (pronounced "254" I suppose...) has a very nice how-to up showing how to use Spotlight metadata to find files from the command line. The post shows how the mdfind command goes beyond find, locate and various grep hacks to create flexible and powerful queries. Surprisingly enough, I couldn't find an mdfind man page (mdutil was there) but the mdfind command worked fine for me in Terminal.

A typical mdfind command goes something like mdfind Sadun, where Sadun is the search word. To limit the search to a particular folder use the -only flag. mdfind -only ~/Desktop Sadun.

The mdls command displays the metadata associated with a specified file. e.g.

% mdls Television\ copy.jpg Television copy.jpg ------------- 
kMDItemAttributeChangeDate = 2006-11-29 11:10:52 -0700 kMDItemBitsPerSample
= 32 kMDItemColorSpace = "RGB" kMDItemContentCreationDate =
2006-11-29 11:10:19 -0700 kMDItemContentModificationDate = 2006-11-29
11:10:19 -0700 kMDItemContentType = "public.jpeg"
kMDItemContentTypeTree = ("public.jpeg", "public.image",
"public.data", "public.item", "public.content") kMDItemCreator
= "Adobe Photoshop CS2 Macintosh" kMDItemDisplayName
= "Television copy.jpg" kMDItemFSContentChangeDate =
2006-11-29 11:10:19 -0700 kMDItemFSCreationDate =
2006-11-29 11:10:19 -0700 (...and so forth...)

It's a great post that goes into far more detail and is well worth a careful read.

This article was originally published on Tuaw.
Greeks demand local Apple support