DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


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
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

OSXFAQ Mac OS X UNIX Tip-of-the-Day  back to index

Spotlight - Pictures and Songs

By Adrian Mayo - Editor - OSXFAQ

Today's tip looks at file content metadata. Different types of file content have different types of metadata. Let's pass a photoshop file to mdls:

$ mdls heart.psd
heart.psd -------------
kMDItemAttributeChangeDate     = 2006-01-03 00:21:09 +0000
kMDItemBitsPerSample           = 40
kMDItemColorSpace              = "RGB"
kMDItemContentCreationDate     = 2004-02-06 02:12:09 +0000
kMDItemContentModificationDate = 2004-02-06 02:12:09 +0000
kMDItemContentType             = "com.adobe.photoshop-image"
kMDItemContentTypeTree         = (
    "com.adobe.photoshop-image", 
    "public.image", 
    "public.data", 
    "public.item", 
    "public.content"
)
kMDItemCreator                 = "Adobe Photoshop 7.0"
kMDItemDisplayName             = "heart"
kMDItemFSContentChangeDate     = 2004-02-06 02:12:09 +0000
kMDItemFSCreationDate          = 2004-02-06 02:12:09 +0000
kMDItemFSCreatorCode           = 943868237
kMDItemFSFinderFlags           = 1024
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 1
kMDItemFSLabel                 = 0
kMDItemFSName                  = "jj1.psd"
kMDItemFSNodeCount             = 0
kMDItemFSOwnerGroupID          = 501
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = 2204679
kMDItemFSTypeCode              = 943870035
kMDItemHasAlphaChannel         = 1
kMDItemID                      = 923966
kMDItemKind                    = "Adobe Photoshop file"
kMDItemLastUsedDate            = 2006-01-03 00:21:09 +0000
kMDItemLayerNames              = (jan, hair)
kMDItemOrientation             = 0
kMDItemPixelHeight             = 718
kMDItemPixelWidth              = 450
kMDItemResolutionHeightDPI     = 72.00006
kMDItemResolutionWidthDPI      = 72.00006
kMDItemUsedDates               = (2005-11-02 12:18:02 +0000, 2006-01-03 00:00:00 +0000)

The last few items show metadata describing the image size, resolution, and even on what photoshop layers it contains.

Try passing a song file to mdls. The metadata includes the genre, title, and bit rate.

...
kMDItemMediaTypes               = (Sound)
kMDItemMusicalGenre             = "Alternative & Punk"
kMDItemStreamable               = 0
kMDItemTitle                    = "Like It Or Leave It"
kMDItemTotalBitRate             = 191384
...

To extract a specific metadata item, pass the item name as an argument to the name option:

$ mdls -name kMDItemAuthors "12 DARE.m4a"
12 DARE.m4a -------------
kMDItemAuthors = (Gorillaz)
$

At this point, you might be tempted to form a 'find/xargs/grep' command line to search through, say, all music for songs a particular Genre. But Apple has provided a much better way of doing this...a command line spotlight.

Tomorrow's tip will look at spotlighting on the command line.

A tip to save you life: "Remember to buy her a card!"


Visit the Site of the Book of the Unix Tips:


Discuss this trick in the OSXFAQ Learning Center forum

E-mail your comments or suggestions to webmaster@osxfaq.com


Copyright © 2000-2008 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.