Reviews Leaderboard Database Reference Search StorageReview Check Storage Prices Discussion FAQs Reliability Survey Search About StorageReview.com Contents

 

Reprinted, with permission, from
The PC Guide


File Names and Extensions

 Reference Guide - Hard Disk Drives 

Author: Charles M. Kozierok 

As virtually every PC user knows, standard PC files are named using a fixed format convention that has been around since the "beginning of time" (i.e., the first IBM PC). The file name is comprised of two parts:

  • File Name: The base name of the file itself. This part of the file name must be between one and eight characters in length. A special code is used as the first character of the file name to indicate deleted files.
  • File Extension: The extension of the file, which is optional and hence can be from zero to three characters.

The extension can be thought of as a "file type" of sorts. It tells you--and your computer--at a glance what kind of file you are looking at. For example, a file with an extension of "EXE" is normally an executable program file, "HTM" usually means an HTML document, and "BAT" a DOS batch file.

In actual fact, there is nothing special at all about these extension names. The reason I say an EXE file is normally an executable file is that the use of the EXE extension to refer to executable files is a convention, and not anything that is enforced by the system. You could open up your editor and type "This is a test", and when you go to save the file, save it as "TEST.EXE", and this will work perfectly fine.

So why are file extensions used? They are essentially a shorthand way of organizing files by type, and they are used by various pieces of software, including DOS itself, to indicate which programs should be used with which files, without having to look into the structure of the file itself. The reason that having an EXE extension on a file matters is that DOS is pre-programmed so that when you type the name of a file, it will look for that file with certain types of extensions to try to execute them. One of those is "EXE". So if you create this silly "TEST.EXE" file with a text line in it and then type "TEST" at the command line, DOS will try to run this "program". What do you think will happen when it does? (Hint: don't try this if you have any unsaved work open anywhere else on your PC...)

Similarly, other programs usually try by default to look only at files that have extensions that they are meant to use. If you run Microsoft Word and go to the "Open" dialog box, by default it will look for files with an extension of "DOC", for "document". This is why using consistent file extensions is important.

This use of file extensions by software programs is quite prevalent, and there are in fact hundreds of different kinds in use. In fact, when you double-click on a file in Windows 95's Windows Explorer, for example, it will automatically launch the program that it knows uses the file you selected, and tell the program to open the file you clicked on. Just remember that Explorer is only determining the program to use by looking at the file extension, and not by analyzing anything within the file itself. (Also, many programs use the same file extensions, which can be confusing at times. If you've ever had Internet Explorer and Netscape Navigator fighting for the "right" to be associated with your "HTM" files you know exactly what I mean. )

The following characters are allowed in legal DOS file names: A-Z 0-9 $ % ' - _ @ ~ ` ! ( ) ^ # &. Note that a space is an officially valid character for a file name, but I strongly recommend against using spaces in standard file names because many programs become very confused by file names with spaces in them. Even Windows 95 specifically avoids using spaces in file names when it creates 8.3 aliases for its long file names.

Next: Long File Names

Return to the top of this page
© Copyright 1997-2005 Charles M. Kozierok. All Rights Reserved.
Write: Webmaster