• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 4. Programs and Documents > How Documents Know Their Parents

4.5. How Documents Know Their Parents

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

Many Macintosh documents come complete with invisible, behind-the-scenes, four-letter type and creator codes (see Figure 4-12).

Figure 4-12. If, one rainy Saturday afternoon, you were feeling especially inquisitive, you could download a freeware program like FileInfo, shown here. If you drag a document's icon onto it, the program shows you the invisible type and creator codes—but this won't be on the exam.

The creator code for a program and the documents it creates are identical—MSWD 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 match—if, say, you double-clicked a document with creator code BOBO, which corresponds to the AppleWorks entry in your desktop database—then the corresponding program opens the document, which now appears on your screen.

4.5.2. File Name Extensions

In 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 Extensions

Exactly 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; you'll 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 Programs

Unfortunately, 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 graphic—Word, 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: Reassigning a certain document—just once

Double-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 program—like iPhoto.

To do so, you must access the Open With command. You can find it in two places:

  • Highlight the icon, and then choose File → Open With.

  • Control-click the file's icon (or right-click it, if your mouse has two buttons). From the contextual menu, choose Open With.

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.

Figure 4-13. Top: The shortcut menu offers a list of programs capable of opening an icon. If you were to press the Option key right now, the words Open With would suddenly change to say Always Open With.
Bottom: If you choose Other, you'll be prompted to choose a different program. Turn on Always Open With if you always want this document to open in the new parent program. Otherwise, this is a onetime reassignment. Reassigning a certain document—permanently

After 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:

  • In the Choose an Application dialog box, turn on "Always Open With" (shown at bottom in Figure 4-13).

  • Start out with one of the techniques described above (File → Open With, or Control-click the file's icon and choose Open With)—but after you see the menu, press the Option key, too. Before your very eyes, the Open With command changes to say Always Open With.

  • Highlight the icon, and then choose File → Get Info. Open the "Open with" panel. Choose a new "parent" program's name from the pop-up menu. You'll see that the word "(default)" changes position, now tacking itself onto the name of the new program you've chosen.


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 example—reminds 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.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint