8.3. Metadata and File AttributesThe prefix meta- implies a state of transcendence. It's used to describe the derivatives and successors of a lot of different things (think metaphysics). It should come as no surprise then that metadata is often described as "data about data." What may be surprising, however, is just how much data about your data is available. While the file's owner and filename would be obvious picks, there are many other pieces of metadata embedded in your files. Take a snapshot from your digital camera as an example. In addition to the basic information that can be derived from the filesystem, even more details are kept in the Exchangeable Image File Format (EXIF) data within the file. This information was added to the file by your digital camera when you snapped the picture. These tidbits of data are not only valuable when working within your imaging software, but they are also indexed in the Spotlight data store for searches down the road. 8.3.1. SpotlightThe introduction of Spotlight technology in Mac OS X Tiger has brought file metadata to the foreground. Spotlight is a powerful tool for searching your data, but it's much more involved than belied by the simple search box presented when you click the Spotlight icon in the menu bar. Spotlight is constantly running in the background, updating its data store whenever the files on your drive change, and making the latest content and metadata available for immediate searching. At the same time, it is handling search requests from Spotlight-powered applications. As you browse a Smart Folder in the Finder, Spotlight works to populate that folder with the appropriate files. When you're looking through a Smart Mailbox in Mail, Spotlight ensures all messages that meet your criteria are visible. Developers are beginning to make their applications Spotlight aware, extending not only their own software with Spotlight support, but also extending Spotlight itself with support for new file formats and metadata schemas. Spotlight is far more than just a search interface; it's an entire system framework dedicated to helping you find your data as quickly as possible.
Apple has provided two useful command-line tools for working with Spotlight data. The mdfind command, discussed earlier in the chapter, allows you to search the Spotlight store for all files that meet your criteria. The mdls command, however, shows you all Spotlight data for an individual file. Figure 8-7 is a look at some of an audio file's metadata, as reported in iTunes. Example 8-12 shows the metadata for that same file (I've trimmed the output for display purposes), as reported by the mdls command. Figure 8-7. An audio file's metadataExample 8-12. Viewing a file's Spotlight metadata with mdls$ mdls "01 Handle with Care.m4a" 01 Handle with Care.m4a ------------- kMDItemAlbum = "Traveling Wilburys, Volume I" kMDItemAttributeChangeDate = 2005-04-16 21:17:50 -0400 kMDItemAudioBitRate = 190672 kMDItemAudioChannelCount = 2 kMDItemAudioEncodingApplication = "iTunes v4.7, QuickTime 6.5.2" kMDItemAudioTrackNumber = 1 kMDItemAuthors = ("Traveling Wilburys") kMDItemCodecs = (AAC) kMDItemComposer = "Bob Dylan / Jeff Lynne / George Harrison / Tom Petty / Roy Orbison" kMDItemContentCreationDate = 2004-12-13 08:23:16 -0500 kMDItemContentModificationDate = 2004-12-13 14:34:40 -0500 kMDItemContentType = "public.mpeg-4-audio" kMDItemContentTypeTree = ( "public.mpeg-4-audio", "public.audio", "public.audiovisual-content", "public.data", "public.item", "public.content" ) 8.3.2. Type and Creator CodesIn Example 8-11, you can see that GetFileInfo is telling you much more about the file than its access attributes. While the rest of that information is pretty self-explanatory, the Type and Creator codes may not be familiar to you. A file's Type code is a case-sensitive, four-character string used by the filesystem to denote the file's type. Type codes can be assigned at file creation and must be four characters in length. Table 8-10 lists some common Type codes. In this table, an underscore means that a space is used where the space character should be (remember, Type codes have to be exactly four characters).
A Creator code is similar to a Type code, except that it denotes the application that was used to create the file. Like Type codes, Creator codes are also exactly four characters in length and are case-sensitive. Table 8-11 lists some common Creator codes.
Looking again at Example 8-11, you can see that the file Type is XLS8, which means that it's an Excel document, and the Creator code is XCEL, which means it was created by Microsoft Excel. Type and Creator codes are used by the Finder to determine the type of a document and the application that should be used to open it. You can see this information in the Finder by choosing File Get Info (-I).
|