Using the mdfind and mdls command line utilities to get at the Spotlight databases in Mac OS X.
mdfind
mdls
http://0xfe.blogspot.com/2006/03/using-spotlight-from-os-x-commandline.html