![]() |
| |||||||
|
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
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||