DOS Lesson 7: DOS Filenames; ASCII

DOS Filenames

DOS filenames follow what is called the 8.3 convention.
This means that all DOS filenames have two parts, with up to 8 and 3 characters
respectively. The first part is also often referred to as the filename, which
can be a little confusing, but there you have it. This part can have anywhere
from 1 to 8 characters in it. This is followed by the extension,
which can have from 0 to 3 characters. Separating these two parts is a period,
but in computer language we never call it a period, we call it a dot.

Filenames can use any letter of the alphabet or any numeral. Many
of the other characters found on a keyboard are also allowed, but not all of
them. That is because many of these other characters have been assigned a special
use in DOS. Among the characters that can appear in a DOS filename are:

~ ! @ # $ % ^ & ( ) _ – { } `

In addition, there are characters in the extended ASCII set that
can be used, such as �. We will discuss ASCII below.

Characters which have a special meaning in DOS, and which cannot
therefor be used in filenames, include:

*/ + | \ = ? [ ] ; : ” . < > ,

Also, you cannot use a SPACE in a DOS filename. (Though you can
simulate one using the appropriate ASCII character, as discussed below). The
reason is that DOS uses spaces to separate items in the command line (see Lesson

Finally, it does not matter whether you use upper case or lower
case letters. DOS converts all letters to uppercase before it deals with them,
so your files will all wind up with uppercase letters in the name no matter
what you do.

File Extensions

A file in DOS does not need to have an extension. You can test
this quite easily by creating a file called FOO and saving it
in your DOS test directory. Do a directory listing using the DIR command, and
you will see it listed. But the file extension does have its uses in DOS. Certain
file extensions have built-in meanings in DOS, such as:

EXE = An executable file

COM = A command file

SYS = A system file

BAT = A batch file

Other extensions are created by a particular software program,
or by you when you create a file. One thing that is very different in DOS, when
compared to Windows, is that DOS does not have the “associations”
that Windows has. In Windows, for instance, a *.DOC file will typically be “associated”
with Microsoft Word, and if you attempt to open this file it will automatically
call Word, open it, and load the file. DOS does not have any of this. You may
have used a DOS shell program, such as Norton Desktop, which gave
you some of these capabilities. Or, if you want to look at it that way, the
ultimate DOS shell program was Windows, at least up the 3.11 level.

In any case, DOS does not have file associations, so if you used
a DOS word processor it didn’t particularly matter what extension you used for
your files. You could get creative, and use extensions as part of your filing
system if you wanted. For instance, you could name your memos using *.JAN, *.FEB,
*.MAR, etc. to help keep track of them.

However, if you are using a DOS window on a Windows machine, you
need to keep the needs of Windows in mind, and be more careful with your file


is an acronym for American Standard Code for Information
Interchange. ASCII is a 7-bit coding system for creating the letters,
numbers, and punctuation characters needed to create basic text files. A simple
calculation shows that 7 bits allows 128 possible characters (2^7=128). The
same seven bits can be thought of as a number, however, which means that we
can think of letters and punctuation marks as being numbers in this particular
coding scheme. Bearing in mind that computer numbering schemes always begin
with a zero, the possible numbers run from 0 to 127. To see how this works,
boot into DOS, make sure the NumLock is set on, hold down the ALT key, and type
a number from 0 to 127 using the number pad. After typing the number, release
the ALT key and look at the result. You should see a character of some kind
appear. You must use the number pad for this exercise, not the numbers at the
top of the keyboard, BTW. Also, this works just as well in Windows as in DOS.
I’m using this right now to generate the characters not normally available in
my HTML editor

You may note that the name of this includes the word American.
What about people in other countries who want to use characters not usually
found in American words? The answer was to add one more bit, creating an 8-bit
system called extended
(see chart here). This system has twice as many possible characters
(256) running from 0 to 255. The first half is the same as ASCII, but in the
second half characters like ß and à were added. This made the extended
ASCII code more universal. But it still has limitations, which is why even more
comprehensive code sets, such as Unicode, are being introduced.

Now, the trick for simulating a space in a file name is this:
In the file name, add the character ALT + 255. This will look exactly like a
space, but to the computer it is something completely different. Note that if
you want to use any DOS commands involving this file you will have to use the
character ALT + 255 in the appropriate place or the file will not be recognized
and you will get a “file not found” error. You could use this in a
DOS environment as a kind of primitive security. No one could delete this file
unless they knew to add the appropriate ALT + 255.

Test file tip!

For those who want to test out these ideas we discuss each week,
I suggest creating a directory on your hard drive, like C:\DOSTEMP, or C:\DOSTEST,
to play around in without messing up anything else on your computer. You can
then create files and subdirectories in here to test out all these procedures.
Since creating files to test things is something you do a lot of, here is a
genuine geeky trick to amaze your friends with. You can create a file directly
form DOS without using any other program, even DOS EDIT. Here is how.

C:\DOSTEMP>copy con

This is a test file.


If you do exactly what I have typed above, you should get back
a response from the computer that says:

1 file(s) copied

Here is what is going on:

First, you are copying a file. You know about the copy command,
it copies a file from one place and puts it in another place. Where is the file
being copied from? It is being copied from con, which is DOS shorthand
for console. The console in this case is your screen. The file
is going to be copied to, which will be created in the
C:\DOSTEMP directory.

Once you enter this command, the computer is just waiting for
you to type in the contents of this file. You will notice that after you hit
the ENTER key you do not get a command prompt. That is because the computer
is waiting for you to enter the contents of this file called FOO.BAR. So you
type something like “This is a test file.” Again, you hit the ENTER
key, but still no command prompt. The computer thinks you may still want to
enter stuff. To tell the computer you are done, you need to enter an End Of
File (EOF) marker. You do that by holding down the Control key,
and while it is down, hitting the “Z” key. The result should look
like “^Z” on your screen. If you hit the ENTER key this time, the
computer will copy the line “This is a test file.” into a file called
FOO.BAR, and give you the response “1 file(s) copied”. Pretty neat,