4.5. How Documents Know Their ParentsEvery operating system needs a mechanism to associate documents with the applications that created them. When you double-click a Microsoft Word document icon, for example, Mac OS X needs a way to know that you want Microsoft Word to launch and open the document. In Windows, almost every document bears a three-letter file name suffix. If you double-click something called memo.doc , it opens in Microsoft Word. If you double-click memo.wri , it opens in Microsoft Write, and so on. Mac OS 9 used a similar system, except that you never saw the identifying codes. Instead, it relied on invisible, four-letter creator codes and type codes . So why would you, a state-of-the-art Mac OS X maven, care what Mac OS 9 did? Because, as a Macintosh/Unix hybrid, Mac OS X uses both creator codes (like Mac OS 9) and file name suffixes (like Windows). It's possible to live a long and happy life without knowing anything about these codes and suffixes. But if you're prepared for a little bit of technical bushwhacking, you may discover that understanding creator/type codes and file name suffixes can be useful in troubleshooting and customizing Mac OS X. 4.5.1. Type and Creator CodesMany Macintosh documents come complete with invisible, behind-the-scenes, four-letter type and creator codes (see Figure 4-12).
The creator code for a program and the documents it creates are identicalMSWD for Microsoft Word, 8BIM for Photoshop, and so on. That's the entire point: The creator code tells the Mac which program to open when you double-click a particular document. The type code , on the other hand, specifies the document's file format. Photoshop, for example, can create graphics in a multitude of different formats: GIF, JPEG, TIFF, and so on. If you inspect your Photoshop documents, therefore, you'll discover that they all share the same creator code, but have a wide variety of type codes. When you double-click a document, Mac OS X checks to see if it has a creator code. If so, it then consults an invisible database of icons and codes. This database is the master index that lists the correspondence between creator codes and the applications that generate them. Together, the type and creator codes also specify which picture appears on a particular icon. If the desktop file discovers a matchif, say, you double-clicked a document with creator code BOBO, which corresponds to the AppleWorks entry in your desktop databasethen the corresponding program opens the document, which now appears on your screen. 4.5.2. File Name ExtensionsIn Mac OS X, though, plenty of documents don't have type and creator codes. Documents created by Cocoa programs (Section 4.8), for example, generally don't. That's because Mac OS X is a Unix operating system. In Unix, type and creator codes are unheard of. Instead, what determines which program opens when you double-click a document is its file name extension , just as in Windows. A file name extension is identifiable by a suffix following a period in the file's name, as in Letter to Mom.doc . The bottom line is that Mac OS X offers two different mechanisms that associate documents with the programs that created them. Mac OS X looks for type/creator codes first. Where they're absent, the file name suffixes kick in. 4.5.3. Hiding and Showing File Name ExtensionsExactly as in recent versions of Windows, Mac OS X comes set to hide most file name extensions, on the premise that they make the operating system look more technical and threatening . If you'd like to see them, however, choose Finder Preferences Advanced and turn on "Show all file extensions." Now examine a few of your documents; youll see that their names display the previously hidden suffixes. You can hide or show these suffixes on an icon-at-a-time basis, too (or a clump-at-a-time basis) using the Get Info window; see Section 2.12.2. 4.5.4. Reassigning Documents to ProgramsUnfortunately, type and creator codes aren't of much use when you encounter a document created by a program you don't have. If your friend emails you a PowerPoint file, you won't be able to open it by double-clicking unless you have PowerPoint installed, too. Even if you have a different presentation program on your hard drive, just double-clicking the file won't always, by itself, open it. The file name extension system, meanwhile, has problems of its own. File name extensions are even less likely to pinpoint which parent program should open a particular document. Suppose you've downloaded a graphic called Sunset.JPG. Well, almost any program these days can open a JPEG graphicWord, Preview, Safari, and so on. How you tell Mac OS X which of these programs you want to open the file? The solution is simple. You can reassign a document to a specific program (or all documents of its kind). Here's the rundown: 4.5.4.1. Reassigning a certain documentjust onceDouble-clicking a graphics file generally opens it in Preview, the graphics viewer included with Mac OS X (see Section 14.16). Most of the time, that's a perfectly good arrangement. But Preview's photo-editing features don't hold a candle to a program like, say, iPhoto. If you wanted to edit such a file, you'd want it to open, just this once, into a different programlike iPhoto. To do so, you must access the Open With command. You can find it in two places:
In any case, study the submenu for a moment (Figure 4-13, top). The program whose name says "(default)" indicates which program usually opens this kind of document. From this pop-up menu, choose the name of the program you'd rather open this particular file, just this once.
4.5.4.2. Reassigning a certain documentpermanentlyAfter opening a TIFF file in, say, Photoshop for editing, you haven't really made any changes in the fabric of your Mac universe. The next time you double-click that file, it will open once again in Preview. If you wish this particular file would always open in Photoshop, the steps are slightly different. In fact, there are three different ways:
Tip: You can use this method to reassign the parenthood of a whole flock of selected icons at once. Once you've selected them, just hold the Option key, choose File Show Inspector, open the "Open with panel, and choose a new program from the pop-up menu. The message at the top of the window"22 items," for examplereminds you that you're changing the whole batch at once. In fact, if you follow up by clicking Change All beneath the pop-up menu, you can reassign all TIFF files to open in Photoshop, not just the specific one or batch that you highlighted. Mac OS X asks you to confirm by clicking Continue or pressing Enter. From now on, double-clicking any similar kind of document (one that has the same file name extension) opens it in the newly selected program. |