|


| NAVIGATION |
|
Home |
|
Store |
|
|
| INSIDE MAC |
|
Television Shows |
|
Broadcast Shows |
|
Daily News Shows |
|
Special Shows |
|
|
| EVENTS |
|
|
|
|
|
|
|
|
| DAILY TIPS |
|
Design |
|
Mac OS X |
|
Mac OS X UNIX |
|
|
| COMMUNITY |
|
Surveys |
|
|
| NEWS |
|
Current |
|
Press |
|
Archive |
|
|
| FEATURES |
|
Editorial |
|
Dr. Mac |
|
Reviews |
|
Reader Reports |
|
|
| RESOURCES |
|
FAQ |
|
Documentation |
|
Learning Center |
|
MAN pages |
|
Glossary |
|
Tutorials |
|
Tips |
|
Links |
|
|
|

|
|
|
OSXFAQ Mac OS X UNIX Tip-of-the-Day
Spotlight - Spotlight from the Command Line
So far we've seen how to examine file metadata using the mdls command. To search the file system for specific content or metadata, use mdfind. Here's an example to search for the text "DOCSIS MIB" (it's a cable TV term):
$ mdfind "DOCSIS MIB"
/Users/saruman/1dot1/Miri/emulator/design/figure-1.psd
/Users/saruman/Sites/adrian/data-base/rfc-index.txt
/Users/saruman/1dot1/Miri/emulator/proposals/Emulator.swx
/Users/saruman/1dot1/Miri/emulator/design/Emulator.pdf
These results should match those found by pressing Command-Space and entering the same term into the Spotlight bar.
Here's another example:
$ mdfind "miranda"
/Users/Shared/Books/Folders/Shakespear/COMEDY/TEMPEST.PDF
Or:
$ mdfind "kiss me, kate"
/Users/Shared/Books/Folders/Shakespear/COMEDY/LOVESLAB.PDF
/Users/Shared/Books/Folders/Shakespear/COMEDY/MEASURE.PDF
/Users/Shared/Books/Folders/Shakespear/COMEDY/SHREW.PDF
/Users/Shared/Books/Folders/Shakespear/COMEDY/TEMPEST.PDF
Why does this search produce more results than just SHREW.PDF? Because Spotlight is looking for
kiss AND me AND kate
(it ignores the comma) but not necessarily consecutively. If all three words appear somewhere in a document, that document will match the search.
We can also look for specific metadata. Tuesday's tip showed us that songs include the metadata item
kMDItemMusicalGenre
Let's search for all songs that are 'Hip Hop/Rap':
$ mdfind "kMDItemMusicalGenre == 'Hip Hop/Rap'"
/Users/sharing/Music/iTunes/iTunes Music/Compilations/Encore/01 Curtains Up.m4a
/Users/sharing/Music/iTunes/iTunes Music/Compilations/Encore/02 Evil Deeds.m4a
/Users/sharing/Music/iTunes/iTunes Music/Compilations/Encore/03 Never Enough.m4a
/Users/sharing/Music/iTunes/iTunes Music/Compilations/Encore/04 Yellow Brick Road.m4a
/Users/sharing/Music/iTunes/iTunes Music/Compilations/Encore/05 Like Toy Soldiers.m4a
Use mdls to discover other types of metadata for other content types.
Tomorrow's tip will show how to perform more complex searches using mdfind.
|


|
Copyright © 2000-2010 Inside Mac Media, Inc. All rights reserved. |
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users. |
| Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc. |
|