Learn about the technologies behind the Internet with The TCP/IP Guide!
NOTE: Using robot software to mass-download the site degrades the server and is prohibited. See here for more.
Find The PC Guide helpful? Please consider a donation to The PC Guide Tip Jar. Visa/MC/Paypal accepted.
View over 750 of my fine art photos any time for free at DesktopScenes.com!

[ The PC Guide | Systems and Components Reference Guide | Hard Disk Drives | Hard Disk Logical Structures and File Systems | FAT File System Disk Volume Structures ]

File Names and Extensions

As virtually every PC user knows, standard (DOS-based) 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.

Since the file name is limited to eight characters and the extension to three, the conventional DOS naming scheme is sometimes called 8.3 naming.

The file extension is occasionally the source of some confusion. Modern operating systems use them as a "file type" of sorts. They tell you--and your operating system--what kind of file you are looking at, at a glance. 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.

However, it's important to remember that there is nothing special at all about these extension names. There is nothing inherently different between an "EXE" file, an "HTM" file, and a "BAT" file--they are all "just files" to the file system, and any special meaning arising from the file extension is a function of the operating system and software, and how they interpret them. For example, I said that an EXE file is normally an executable file, because 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 text 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. The text editor may default to a different extension, but it won't cry foul at your choosing "TEST.EXE" as a file name.

So why are file extensions used? They are essentially a shorthand way of organizing files by type. They are used by various pieces of software, including DOS and Windows themselves, 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 the operating system 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? Probably just an error message, but you can cause errors or confuse applications by changing file extensions (which is one reason why Windows will warn you if you try to change a file extension in Windows Explorer.)

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". Graphics programs will look for "JPG" or "GIF" files, amongst others. This standard functionality is why using consistent file extensions is important.

This use of file extensions by software programs is now universal, and there are in fact hundreds of different kinds in use. Windows maintains a list of file associations that tell Windows Explorer which programs go with which file types (extensions). When you double-click a file in Explorer to open it, Explorer 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. :^) )

Tip: You can change the program associated with any file extension by editing the file associations. Within Windows Explorer, select "Options..." from the "View" menu. Then click the "File Types" tab, select the item to be modified, and select "Edit...". Find the file type you want to modify, highlight the "open" Action, and select "Edit..." again. Change the program and close all the windows and you should be all set. Note that some programs will automatically "re-establish" associations to themselves whenever you run them! (They are supposed to ask first but software writers can be a tad, uh, possessive. :^) )

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 9x/ME specifically avoid using spaces in file names when they create 8.3 aliases for long file names.

Next: Long File Names

Home  -  Search  -  Topics  -  Up

The PC Guide (http://www.PCGuide.com)
Site Version: 2.2.0 - Version Date: April 17, 2001
Copyright 1997-2004 Charles M. Kozierok. All Rights Reserved.

Not responsible for any loss resulting from the use of this site.
Please read the Site Guide before using this material.
Custom Search