Section 8.3. Metadata and File Attributes


8.3. Metadata and File Attributes

The 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. Spotlight

The 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.

Spotlight on Privacy

Sometimes you have data that you don't want to be indexed. Maybe it's a confidential spreadsheet or pictures of that new secret prototype. Either way, you can keep Spotlight from indexing your data through its Privacy preferences. To specify which folders Spotlight should ignore, open System Preferences ( System Preferences) and select the Spotlight pane.

Once you're in the Spotlight preferences, you'll see a Search Results tab that allows you to control the types of results shown in your Spotlight search window. You'll also see a Privacy tab where you can list folders whose contents you want Spotlight to ignore when indexing.


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 metadata


Example 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 Codes

In 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).

Table 8-10. Common Type codes

File extension

Type code

Type of file

.pdf

PDF_

Portable Document File

.doc

W8BN

Microsoft Word document

.xls

XLS8

Microsoft Excel document

.psd

8BPS

Adobe Photoshop document

.dmg

devi

Disk image

.mov

MooV

QuickTime movie

.jpeg, .jpg

JPEG

JPEG image file


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.

Table 8-11. Common Creator codes

Creator code

Application

PRVW

Preview

MSWD

Microsoft Word

XCEL

Microsoft Excel

8BIM

Adobe Photoshop


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).

An Aside on Extensions

Type and Creator codes have been a part of the Mac almost as long as there's been a Mac. They've never been a part of Windows, however, leading to frustrated users on both sides. Microsoft Windows makes use of three-character file extensions to specify a file's type. It then uses file associations to determine which application handles the file. Both get you the same results, though the HFS+ approach offers more finite control, allowing you to specify the handler on an individual file basis.

Unfortunately, the two systems are ignorant of each other, leaving the duty of picking the right application to the user. Inevitably, a Mac user would forget to add that file extension or might encounter an extension she just isn't familiar with. Today it's not as much of a concern: Mac OS X is a much friendlier cross-platform client than its predecessors, providing excellent support of both file extensions and HFS+ Type and Creator codes.

If you still end up coming across an unfamiliar file extension, you'll find some great resources on the Internet for tracking down a compatible application. A search of the file extension will likely yield good results, but you might have better luck searching a site like http://www.filext.com.





Running Mac OS X Tiger
Running Mac OS X Tiger: A No-Compromise Power Users Guide to the Mac (Animal Guide)
ISBN: 0596009135
EAN: 2147483647
Year: 2004
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net