home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
COMPUSCI
/
DOSIMP12.ZIP
/
SIMPLY5.HYP
< prev
next >
Wrap
Text File
|
1992-01-16
|
111KB
|
1,982 lines
What Are |tExecutable|t Files?
An |nexecutable|n file actually means any file with the extension .EXE, but
in general, it means any file that the computer can execute as a command.
There are two |nexecutable|n extensions other than .EXE, and they are .COM
and .BAT. A file with the .BAT extension is a batch file, and a file
with the .COM extension is a command file. There's another misleading
term, because generally any .EXE, .COM, or .BAT file is a command.
Files that do not have one of these three extensions cannot be executed.
They can only be used as parameters to some other command. For example,
.SYS files are |sdevice driver|ss which are used as parameters to the DEVIC|1E
command in the CONFIG.SYS file. .WK1 files are spreadsheets, .DBF files
are data bases, .DOC files are word processor documents, .BAS files are
program files in the BASIC language that can only be read by the BASIC,
BASICA, GWBASIC, or QBASIC interpreters. These are just a few of the
most common non-|nexecutable|n file extensions.
When executing a command, it is not necessary to type the command file's
<page down> for more Executable
extension, just the filename. First DOS looks at the copy of COMMAND.COM
in memory to see if there is an internal command with that name. If so,
DOS will execute the command. If not, DOS will look in the current dir-
ectory for a file with that name and the extension .COM. If not found,
DOS will look for a file with that name and an .EXE extension, and if not
found, a .BAT extension. If none of those are found in the current dir-
ectory, then DOS will search for those same filenames in each directory
listed on the PATH variable in the environment. If no |nexecutable|n file
with that name is found in any of these places, you'll see the famous
"|tBad command or filename|t" message.
However, if the full file specification (|spath|sname) to the command is in-
cluded on the command line, the only place DOS will search for a .COM,
.EXE, or .BAT file with that name, is in that specified |sdirectory|s! DOS
won't even execute an internal command if one exists by that name, if the
directory is specified on the command line. So if you should for some
reason need to have a command file named |nCLS|n.EXE, it is possible to have
that file executed even though DOS searches the internal command table
before searching any directories. You just need to specify the path to
<page down> for more Executable
the |nCLS|n.EXE file on the command line, or else if the |nCLS|n.EXE is in the
current directory, use the shortcut .\CLS. (See also ". and ..".) That
will execute the |nCLS|n command file rather than the CLS internal command.
If you have a file named HELLO.EXE and a file named HELLO.COM, or if you
have two different HELLO.COM files in two different directories, the one
that's closest to the beginning of the PATH variable is always the one
that will get executed, unless you're in the same directory with the
other one, or you specify the |spath|sname on the command line.
Now here's something interesting that I recently found out. Every single
DOS book that I've ever read which has brought up this subject has said
the following: If there is a .COM file, an .EXE file, and a .BAT file
with the same first name, in the same directory, then there is no way
the .EXE or .BAT files will ever be executed, not even if you enter the
command as FILE.EXE or FILE.BAT, because DOS will just ignore the exten-
sion of the file and look for a command in the normal order: internal,
then .COM, then .EXE, and then .BAT.
<page down> for more Executable
Well that was true in earlier versions of DOS, but it is not true any
more, and the DOS manual authors just haven't figured it out yet. I just
copied |nCHKDSK|n.COM and |nGWBASIC|n.EXE to an empty directory, renamed them to
TEST.COM and TEST.EXE, and created a TEST.BAT file that just said, "|sECHO|s
It works!" Now what I had was three different commands that all had the
first name of TEST. So I entered the command TEST and what got executed
was CHKDSK, which had been renamed to TEST.COM. That's just what should
have happened.
Now according to all the DOS books, when I entered TEST.EXE as a command,
I should have gotten a CHKDSK report once again. Nope. I got GWBASIC.
Then when I entered TEST.BAT, I got "It works!"
This works for me with MS-DOS versions 4.01 and 5.0, but not with 3.2 or
3.3. But even the books that say they are updated for version 4.01 are
still saying it can't be done. This just goes to show that you can't al-
ways be sure of anything when it comes to computers. Just because some-
thing was true in 1983 doesn't mean it's still true in 1991, even if all
the DOS books are still saying it!
<page down> for more Executable
As a matter of fact, remember what I said about executing an .EXE file
with the same first name as an internal command, like |nCLS|n.EXE? All the
books also say that is impossible, unless you patch your COMMAND.COM file
to change the name of the internal CLS command. But it's not true. You
don't have to patch COMMAND.COM to execute a |nCLS|n.EXE file. You just have
to specify the |spath|sname of the file on the command line, like I said. I
just tested it on MS-DOS versions 3.2, 4.01, and 5.0 to make sure before
I said it. No problem.
Books are not always right! (Now doesn't it make you feel good, to know
that?) These things were true for so long, in all the earlier versions
of DOS, that everyone, even the authors of the DOS books, just accepts
them as gospel, without even testing to find out whether they're still
true or not.
(As a matter of fact, I have about two dozen DOS books, and over half of
them are chock full of errors, typos, mistakes, and misinformation. It's
just about as silly to trust a computer book as it is to trust a computer
salesman!)
<page down> for more Executable
Ready for some more confusion? |nExecutable|n files can be called commands,
utilities, programs, or applications! There are some vague differences
between these terms, but they're basically interchangeable, more or less.
Internal commands, those that are inside the COMMAND.COM file, are defin-
itely called commands. The DOS commands that require |nexecutable|n files
can be called external commands, or DOS utilities, or DOS programs. Ex-
ecutable files that don't come from DOS can be called programs, utilit-
ies, or applications. A utility almost always refers to some command
that performs a very specific function, and that does not require any
overlay or support files. A program can mean either a utility or an app-
lication. And an application is usually a great big program that should
have a whole directory all to itself, that has a whole bunch of |soverlay|ss
and support files, that is used to do your work, not just for things that
are only related to the computer itself. Examples of applications are
word processors, database managers, spreadsheets, desktop publishers, ac-
counting or payroll programs, things like that. But you can't run any of
these without an |nexecutable|n file, with the .COM, .EXE, or .BAT extension.
<page down> for What Is COMMAND.COM?
What Is |tCOMMAND.COM|t?
This is one of the top three most important files on your system. The
others are IO.SYS and MSDOS.SYS for MS-DOS, or IBMBIO.COM and IBMDOS.COM
for PC-DOS. Without these three files in the right place so that the
computer knows where to find them, the computer can't even boot up.
|nCOMMAND.COM|n is the part of DOS that interprets every command you type in
at the DOS prompt. It also has lots of commands inside of it, and these
are called |tinternal|t commands. Here is a list of them:
BREAK CLS DEL EXIT LOADHIGH PROMPT SET TYPE
CALL COPY DIR FOR MKDIR REM SHIFT VER
CHCP CTTY ECHO GOTO PATH RENAME TIME VERIFY
CHDIR DATE ERASE IF PAUSE RMDIR TRUENAME VOL
As long as your version of DOS includes these commands, you can enter any
of them at any prompt, any time, whether you have a PATH variable in your
environment at the moment, or not. (|sGOTO|s, PAUSE, REM, and SHIFT are
batch file commands that have no useful purpose at the command line.)
<page down> for more COMMAND.COM
These are some other commands that can sort of be considered as internal
commands, because the code that tells DOS how to execute them is inside
the IO.SYS file (or the IBMBIO.COM file if you're using PC-DOS), and they
can only be used from within the CONFIG.SYS file, not at the command line
or from a batch file or anything like that:
BREAK COUNTRY DEVICEHIGH DRIVPARM FILES LASTDRIVE SHELL SWITCHAR
BUFFERS DEVIC|1E DO|1S FCBS INSTALL REM STACKS SWITCHES
They're really not referred to as internal commands, though. They're
usually just called CONFIG.SYS commands. (Yes, BREAK and REM are both
internal commands and CONFIG.SYS commands. The code that executes them
is in both the IO file and the |nCOMMAND.COM|n file, so they can be executed
from CONFIG.SYS or the command line or a batch file.)
All the rest of the DOS commands are |texternal|t, and that means that in
order to execute them you have to have the executable file by that name
available to DOS in order for DOS to run the command.
See also SHELL, COMSPEC, COMMAN|1D, and Shelling Out for more information.
<page down> for The COMMAND Command
The |TCOMMAN|1D|T Command
COMMAND is the command that activates a secondary shell of COMMAND.COM.
Secondary shell, you ask? Well yes, because if there were not already a
primary COMMAND.COM shell, then your computer would just be sitting there
giving you a cold stare, not even a prompt. A COMMAND.COM shell is what
gives you a prompt and then interprets the commands that you enter at the
prompt. That's why it's also called the Command Interpreter. It might
be called a shell because it protects you from having to deal with the
actual binary language that the computer can understand.
Well if you do a lot of shelling out to DOS from inside some application,
what that application is doing is using the COMSPEC variable to find out
where your COMMAND.COM file is, and loading another copy of that file in-
to memory right over top of the application you're working on. When you
are done with what you wanted to do in DOS, you type EXIT and hit <Enter>
and the secondary COMMAND.COM shell drops back out of memory and leaves
you right where you were before, in that application.
<page down> for more COMMAN|1D
Well you can also shell out to a secondary command interpreter right from
the primary command interpreter, without using some application that has
a shelling out option, as a middle man. You probably won't need to do it
very often, but when you do, COMMAND is the command you use.
About the most common reason for a beginner to need to shell out to a
secondary COMMAND.COM is in order to call a second batch file from inside
another batch file. Of course if you have DOS version 3.3 or later, you
would want to use the CALL command. But since that command didn't exist
until DOS version 3.3, some people still need to use the COMMAND command
to accomplish this.
You see, if you just enter the name of a second batch file, as a command
in the first batch file, then control will be passed permanently to that
second batch file. When the second batch file is done, you'll just get a
DOS prompt, and whatever commands were still remaining to be executed in
the first batch file, will never be seen by DOS. So if you want DOS to
come back to the first batch file after the second batch file is done,
you need the CALL command if you have DOS 3.3 or later, or else you need
<page down> for more COMMAN|1D
the COMMAND command with the /C switch. Here is FIRST.BAT:
ECHO This is the first batch file
COMMAND /C SECOND
ECHO Back in the first batch file again
And here is SECOND.BAT:
ECHO This is the second batch file
Now when you run FIRST.BAT, the first ECHO command will be executed, then
a secondary command shell will be loaded and the /C switch tells that
secondary shell to execute the command following the /C. So SECOND.BAT
will be called, and then as soon as it's done, since the /C switch was
used with the COMMAND command, the secondary shell will drop right out
of memory just as if you had issued the EXIT command, and then FIRST.BAT
will continue on with the next ECHO command.
If you don't use the /C switch with the COMMAND command, then you can run
whatever commands or programs you want, and the secondary processor won't
drop out of memory until you give the EXIT command.
If you ever want to perform some DOS command in the middle of a batch
<page down> for more COMMAN|1D
file, and then return to that batch file, you could do it if you had the
COMMAND command in that batch file. The batch file would start running,
and then when it got to the COMMAND command, you'd get a DOS prompt, and
you could do whatever you wanted, and then when you type EXIT, that sec-
ond COMMAND.COM would drop out of memory and the batch file would finish
executing.
Whenever you load a secondary command processor, it gets a copy of your
|ncurrent|n environment. So it has the same PATH, PROMPT, and COMSPEC varia-
bles that you already had, plus whatever else you might have had in your
environment. Then you can do whatever you want to do with the environ-
ment while you're in the secondary shell, and it will not affect the or-
iginal environment. When you EXIT back to the primary shell, you will
still have the exact same environment you had before you loaded the sec-
ondary shell.
Also whenever you load a secondary command shell, it starts out with the
default ECHO ON. So if you use COMMAND /C to call a second batch file
from within another batch file, it does not inherit the same ECHO state
<page down> for more COMMAN|1D
that existed in the first batch file, as happens with the CALL command.
Even if ECHO was off in the first batch file, you'll have to have the
command ECHO OFF at the beginning of the second batch file too if you
want it to have its ECHO off as well.
If you ever run some other shell besides COMMAND.COM, such as the wonder-
ful shareware program from J. P. Software called 4DOS, that's another oc-
casion you might be interested in using the COMMAND command. Suppose you
are running 4DOS as your primary command interpreter, and you're having
trouble getting some particular command to work. You decide that you
would like to try the same command in regular DOS, to see if it's just a
quirk in 4DOS that's giving you trouble, or what. Well you don't have to
edit your CONFIG.SYS file and reboot in order to load a copy of the regu-
lar COMMAND.COM to test your theory. You just use the COMMAND command to
load a secondary shell, try out that command that's giving you trouble in
4DOS, and then use the EXIT command to remove the secondary shell. (This
was not to imply that I think you will find any quirks in 4DOS. It's a
fantastic program! It does just about everything that you ever wished
DOS would do but didn't. 4DOS is about 99.99999% compatible with all the
<page down> for more COMMAN|1D
applications you use under regular DOS, but it's so much better than reg-
ular DOS! It's even better than DOS version 5!)
Here's another use for the COMMAND command. Have you ever wanted to use
a nested FOR command, that is, a FOR command inside another FOR command?
Kinda the same as using COMMAND or CALL to run another batch file from
within a first batch file. Well in general it's not possible to nest FOR
commands. But it can be done using the COMMAND /C command. Want to copy
all the .BAT files from the BELFRY directory, and all the .BAT files from
the UTIL directory, to the disk in drive B:, all in one command? FOR %%A
IN (\BELFRY \UTIL) DO COMMAND /C FOR %%B IN (%%A\*.BAT) DO COPY %%B B:
would do it. Not that you'll probably ever want to, but isn't it nice to
know that it can be done if you ever do?
The COMMAND command also has a /P switch, which you might recognize from
the SHELL command in your CONFIG.SYS file. The switch doesn't belong to
the SHELL command, but to the COMMAND command. It causes the command
processor being invoked, to become the primary command processor, even if
there already is a primary one loaded. This means that it will run the
<page down> for more COMMAN|1D
AUTOEXEC.BAT file, and that it cannot be exited with the EXIT command.
The only way to get rid of a command shell that was invoked with the /P
switch, is to reboot. So you probably won't ever want to use the /P
switch except for with the SHELL command in CONFIG.SYS.
If you use the COMMAND command from within a batch file, it's a good idea
to use %COMSPEC% to reference it. COMSPEC is an environment variable
that points to where your copy of COMMAND.COM is located. And the per-
cent signs are a way that is used in batch files to reference environment
variables. Whenever DOS's batch file interpreter sees a word surrounded
by percent signs, it looks into the environment to see if there is a var-
iable by the name of the word that's inside the percent signs. If there
is, then DOS temporarily replaces the word (for example %COMSPEC%) with
whatever the word is SET equal to in the environment (for example C:\DOS\
COMMAND.COM). So if you put %COMSPEC% into your batch file in place of
the word COMMAND, then DOS will replace that with C:\DOS\COMMAND.COM (if
that's where your COMMAND.COM file is) and the correct copy of COMMAND
.COM will be loaded as the secondary shell. This is good for in case you
ever end up with some other copy of COMMAND.COM on your disk in a direc-
<page down> for more COMMAN|1D
tory that's closer to the beginning of your PATH variable than the copy
of COMMAND.COM that is the one you really want to run. Because DOS will
execute the first COMMAND.COM it finds on the path if you just say COM-
MAND in the batch file. If you say %COMSPEC% instead, in the batch file,
then you know for sure that the correct copy of COMMAND.COM gets loaded.
<page down> for What Is Shelling Out?
What Is |tShelling Out|t?
Many applications have a menu choice where you can get to a DOS prompt
without actually exiting from the application. Then you can do whatever
it was that you wanted to do in DOS, and then when you type |nEXIT|n you get
taken right back to the point where you had been inside your application
before you went to the DOS prompt. This is called "shelling out" to DOS.
The reason it's called that, is because COMMAND.COM, your command inter-
preter, is also called a command shell. When you shell out to DOS from
within another application, what the application does is load a secondary
copy of COMMAND.COM into memory on top of itself, and you do your work in
that secondary shell. The application does that by executing the COMMAN|1D
command, or by using the COMSPEC environment variable to call COMMAN|1D.
The |TEXIT|T command causes the secondary command shell to drop out of mem-
ory, and you find yourself right back where you were before the secondary
shell had been loaded on top of what you had been doing.
<page down> for more Shelling Out
If you forget that you're in a secondary command processor, and you don't
use the EXIT command to get back into the application, and exit the app,
before you turn the computer off for the day, then not only will your
work that you'd been doing inside the application not get saved to disk,
but also you could end up with all sorts of strange files on your disk.
Many applications make temporary working files on the disk, to keep track
of things that they're doing that don't all fit in memory. When you exit
the application, it automatically cleans up after itself and deletes the
temp files that it had been using. If you don't exit the application
properly before turning off the computer, the application never gets the
chance to delete those files.
Also, many applications create yet another temp file on the disk, when
you shell out to DOS, to remind itself how to get back to where it was,
whenever you're done in DOS and type the EXIT command. When you do type
EXIT and go back to the application, the app uses that temp file to find
its way back, and then it deletes that temp file. So if you don't ever
use the EXIT command to get back to the app, then there's another temp
<page down> for more Shelling Out
file that stays on your disk.
An awful lot of beginners (and non-beginners too) have this problem with
the DOSSHELL. It leaves all kinds of temp files laying around, and most
users just can't figure out where they come from. Well, they come from
not properly exiting the DOSSHELL. But I wouldn't say that's the user's
fault, because the Microsoft documentation does a terrible job of ex-
plaining all the different ways of exiting the DOSSHELL. You can use the
"Command Prompt" option in the Main Group, or the Shift-F9 keystroke com-
bination, to shell out to DOS. But if you type DOSSHELL to get back from
there, then what you've done is load a second copy of the DOSSHELL into
memory on top of the first COMMAND.COM, first DOSSHELL, and second COM-
MAND.COM. You don't want to do that. If you use Shift-F9 or "Command
Prompt" to get out of the DOSSHELL, then you have to use the EXIT command
to get back in. Because those two options don't exit the DOSSHELL, they
just shell out to a second copy of COMMAND.COM. There are three ways to
really and truly exit the DOSSHELL, and they all do the exact same thing.
The F3 key, the Alt-F4 combination, and the Exit option under the Files
menu. If you always use EXIT instead of DOSSHELL to get back in after
<page down> for more Shelling Out
having shelled out, and if you always use one of the three methods of
exiting the DOSSHELL before you shut off the computer or reboot, then the
|sDOSSHELL|s's temp files will never get left lying around on your hard disk.
Except of course, once in a while when an application that you had start-
ed from the DOSSHELL locks up on you, and the only way you can get out of
the lockup is to reboot. But that just happens sometimes. It can't be
helped.
In DOS version 4, the |sDOSSHELL|s's temp files have names like 10370F37, and
the version 5.0 DOSSHELL has some really weird ones like 04E2DOSC.BAT,
~7924D01.SWP, and stuff like that. If you use the task swapper, one temp
file for each program you're swapping will be a really huge (around 600K)
Hidden file. You'll have to use the /AH switch with the DIR command in
order to even see their names, and use the ATTRIB command to remove the H
attributes before you can delete them if they get left behind.
So that's how it works with the DOSSHELL, but what about all the other
applications that allow you to shell out to DOS? They work exactly the
same way, but with different keystrokes. How do you know you're properly
<page down> for more Shelling Out
exiting them? Well if the program's documentation doesn't make it clear,
then just try this: Exit the program the way you normally do, and when
you get to the DOS prompt, type EXIT and hit the <Enter> key. If that
takes you back into your program, then you know that the method of exit-
ting you've been using doesn't really exit the program, it only shells
out to DOS. Get out that program's manual and find out the real way to
exit, and always use that way before you shut off the computer.
If typing EXIT at the DOS prompt locks up your computer without even giv-
ing you a message or a prompt, then you have indeed found the way to com-
pletely exit your program to the primary copy of COMMAND.COM, but you al-
so have a SHELL command in your CONFIG.SYS file that doesn't have a /P
switch. The /P switch is what makes the primary COMMAND.COM permanent,
so if you don't have one, and you type EXIT, then the primary COMMAND.COM
drops out of memory just like a secondary one would, leaving you with a
computer that doesn't even know how to show you a prompt. If you have a
SHELL command in CONFIG.SYS, it has to have a /P switch. Then the EXIT
command won't have any effect on the primary COMMAND.COM. It just won't
do anything at all. Which is exactly what you want if you ever type EXIT
<page down> for more Shelling Out
while you're already in the primary COMMAND.COM.
What if you already have some of those funky numbered files on your disk?
Well, they're probably just temp files from your not properly exiting
some application, in which case there's no reason not to delete them.
They're just taking up space on your disk for nothing. Once an applica-
tion is restarted, it has lost its place in the old temp file and there's
no way it can use it again. It can only create a new temp file. But
just in case the strangely-named files you have on your disk right now
are something that one of your applications requires, COPY them to a
floppy for safe-keeping before you delete them from your hard drive, and
then after you see that your app still runs just fine, you can delete
them from the floppy too. If your app doesn't run anymore, then you know
that one or more of those files was something necessary, instead of just
a temp file. So copy them back one by one, to figure out which one it is
that your app needs, leave that one on your disk and just delete the
others.
If you have an application from which you like to shell out a lot, and
<page down> for more Shelling Out
you run that application from a batch file, there is something you can do
to make it easy for you to remember that you're in a secondary shell
rather than the primary one. Suppose the name of this app is WORD and
the batch file from which you run it, is WP.BAT:
@|sECHO|s OFF
CD C:\WORD
PROMPT Shelling from WORD--Type EXIT to return$_$P$G
WORD
PROMPT $P$G
CD \
Now every time you run the WORD application by using WP.BAT, your prompt
will be changed from:
C:\WORD>
to:
Shelling from WORD--Type EXIT to return
C:\WORD>
so that if you shell out to DOS, that's the prompt you'll see and you
can't possibly forget that you're in a secondary shell, and then after
you exit from the WORD application, the batch file puts your prompt back
<page down> for more Shelling Out
to the normal C:\WORD> before it changes back to the root directory and
leaves you in DOS.
Or if you're using the DOS version 5.0 DOSSHELL (this may or may not also
work in the version 4 DOSSHELL; I don't know because I've never used it),
you can change the properties screen of the "Command Prompt" Main Group
menu choice, to make the command that it executes look like this:
PROMPT Type EXIT to Return to Shell$_$P$G ; CLS ; COMMAN|1D ; PROMPT $P$G
so that whenever you use the "Command Prompt" menu option to shell out to
DOS, it will remind you that you're in a secondary shell, and it will al-
so clear the screen for you since the DOSSHELL will mess up any color you
had set up using ANSI.SYS, which the CLS command will put back to normal.
Many programs, including the version 5 DOSSHELL (but not the one in ver-
sion 4), use an environment variable named TEMP (or in some cases, TMP)
to decide where to keep their temp files. So if you have a RAMdisk, put
the line SET |sTEMP|s=D:\ (assuming your |sRAMdisk|s's drive letter is D:) into
your AUTOEXEC.BAT file, and all the temp files for the programs that use
the TEMP variable will be kept on the RAMdisk. Not only does this speed
<page down> for more Shelling Out
up the program, because the RAMdisk is so much faster than the hard disk,
but it also takes care of the leftover temp file problem. Because every-
thing on a RAMdisk disappears when you reboot, so the temp files will al-
ways get deleted even if you don't properly exit the program that created
them. Of course this only applies to programs that use the TEMP variable
to decide where to put their temp files. Programs that don't, won't be
putting the files on the RAMdisk unless you have some other way of tell-
ing them to.
What if you have an application that offers a menu choice of |nshelling out|n
to DOS, but it never works? Well most applications use the COMSPEC vari-
able in the environment to find your copy of COMMAND.COM and load it, but
there are some poorly-written applications that don't do that. They look
in the root directory of the boo|1t disk to find a file named COMMAND.COM
and they load that, without even looking to see what the COMSPEC variable
has to say. If you have an application that does that, and you really do
want to be able to shell out from that app, then you will have to just
leave your COMMAND.COM file in the root directory, and adjust your SHELL
statement in CONFIG.SYS accordingly (or even remove it altogether).
<page down> for The |nCOPY|n Command
The |TCOPY|T Command
This is the command you use to make a copy of one file and put that copy
somewhere else. The original file stays right where it was before. The
syntax is pretty straightforward:
|nCOPY|n D:\DIR\FILE1.EXT D:\DIR\FILE2.EXT
where D: is the drive letter for the original source file and the drive
letter for the copy on the target drive. |nDIR|n is the directory for the
original source file and the directory for the copy on the target drive.
And FILE#.EXT is the filename and extension for the original source file
and the filename and extension for the copy on the target drive.
Most of those parts of the command can usually be left out though. If
the source file is in the current directory of the current drive, then
the first D:\DIR\ part can be left out. (COPY FILE1.EXT D:\DIR\FILE2
.EXT) If the copy of the file that is to be placed on the target drive
is to have the same filename and extension as the source file, then the
FILE2.EXT part can be left out. (COPY D:\DIR\FILE1.EXT D:\DIR) If the
current drive and directory are the target, and the filename and exten-
<page down> for more COPY
sion are to remain the same as the source, then the entire target half
of the equation can be left out. (COPY D:\DIR\FILE1.EXT)
Target files always start out with their Archive attributes set to on,
because they have just been created. But even if the source file had a
Read-only attribute, the target file will not. You'll have to use the
ATTRIB command to set the R attribute of the target file if you want to.
The |nCOPY|n command can also be used to combine two or more files into one.
This is called |tconcatenation|t, but it doesn't always work quite right in
all DOS versions. Always take a look at the target file, and make sure
that it does contain each of the source files, before you even think
about deleting the source files!
Here are some examples of |nconcatenation|n:
|nCOPY|n FILE1 + FILE2 BIGFILE
|nCOPY|n FILE* BIGFILE
|nCOPY|n FILE1 + FILE2
That last one will use the first file specified, FILE1, as the target.
<page down> for more COPY
FILE2 will be appended to the end of FILE1. FILE1 will no longer exist
in its original form, so be careful with that!
It's a good idea to make a quick backup copy of each of the files you're
about to concatenate, before you start. Like this:
|nCOPY|n FILE* FILE*.BAK
|nCOPY|n FILE1 + FILE2
If the files you're trying to concatenate end with <Ctrl-Z>, which is the
ASCII decimal 26, or End-of-File character, then the TYPE command will
show only the first source file when you TYPE the target file. That's
because the TYPE command stops when it finds the first <Ctrl-Z> charac-
ter. A lot of other sorts of programs do the same thing. It will look
as if the concatenation didn't work at all. What to do about that? Well
you can use the /A switch with the |nCOPY|n command, on the source side of
the equation, as in |nCOPY|n FILE* /A BIGFILE. This will cause the files to
be copied up to, but not including, their first <Ctrl-Z> characters. (If
there's more than one of these characters in a file, though, whatever
comes after the first one will be lost.)
<page down> for more COPY
The /A switch on the target side of the equation will cause a <Ctrl-Z> to
be added to the end of the target file.
The /A switch is the default for concatenation, but only when DOS real-
izes that concatenation is what's going on. Sometimes you can trick DOS,
you know. So I just get into the habit of using the /A even when it is
the default, just to make sure DOS realizes that I'm trying to do some
concatenation. There are also times when you want DOS to use the /A
switch when you're not doing concatenation at all. Like if you have a
file that has a <Ctrl-Z> character at the end, and you want to remove
that character, |nCOPY|n /A FILENAME.EXT FILENAME.NEW /B will do it.
There is also a /B switch for the |nCOPY|n command, but it's not needed so
often because it is the default unless concatenation is being done. On
the source side, it tells |nCOPY|n to copy the whole file, according to the
byte size listed in the file's directory entry, including, and past, any
<Ctrl-Z> characters that may be in the file. On the target side, the /B
switch causes a <Ctrl-Z> character to not be added to the end of the tar-
get file.
<page down> for more COPY
An /A or /B switch applies to the file that precedes it, and also to any
files that follow it until the opposite switch is encountered. So a com-
mand like |nCOPY|n FILE1 /B + FILE2 + FILE3 /A + FILE4 /B BIGFILE would cause
the /B switch to apply to all the files except FILE3. And |nCOPY|n FILE1 +
FILE2 /B + FILE3 + FILE4 /A BIGFILE would have the /A switch applying to
FILE1, FILE4, and BIGFILE.
There is also a /V switch for the |nCOPY|n command, which tells DOS to VERIFY
the copy. But this doesn't do very much good, and in fact if you use a
disk cache, it doesn't do a bit of good because DOS will end up verifying
the target file against the copy in the cache, rather than verifying the
target against the source file. If you want to verify your copy, use the
FC or COMP command instead, and see the VERIFY chapter for the reason.
Another use for the |nCOPY|n command is to send or receive data to or from a
device, instead of between two filenames. For example, |nCOPY|n CON FILENAME
will take data from the keyboard (the input half of the CON device) and
send it to a file. |nCOPY|n FILENAME /B CON will display a whole file, even
the parts past the first End-of-File character, on the screen (the output
<page down> for more COPY
half of the CON device). This is about the only way you can display an
entire .COM or .EXE file on the screen with plain old DOS, because most
display methods stop at the first ^Z character, since most display meth-
ods think that's an End-of-File marker.
Another device that's really useful with the |nCOPY|n command is PRN. You
can print out a file with the command |nCOPY|n FILENAME PRN. You can even
use |nCOPY|n CON PRN to make your printer act sort of like a typewriter.
When copying from CON to a filename or to PRN, as soon as you enter the
command, the cursor moves down one line and over to the left edge of the
screen, and sits there waiting for you to type something. You type the
lines of text that you want to send to the file or to PRN, hitting the
<Enter> key after each line, and when you're all done, hit the <F6> key
or the <Ctrl-Z> keystroke combination, hit <Enter> one more time, and
your "file" will be copied to the disk or to the printer. If anyone ever
tells you to hit the <F6> key at the end of the last line, before hitting
<Enter>, instead of hitting <F6> on a blank line of its own, don't do it.
It'll work, but it can also cause problems with that file in the future.
<page down> for more COPY
Another use for |nCOPY|n CON is to add text to the end of a text file without
using a text editor. |nCOPY|n CONFIG.SYS + CON will allow you to add lines
to the end of your CONFIG.SYS file, as long as the last line that was in
that file did not have a <Ctrl-Z> character before its last carriage re-
turn (<Enter> key). That's just one example of the type of problem that
can be caused by putting the <F6> before the <Enter>. The <F6> key, you
see, is what puts the <Ctrl-Z> at the end of a file. You need to have an
<Enter> at the end of the last line of the file before the <F6>/<Ctrl-Z>.
If you want to "move" some files instead of just copying them it's really
sensible to always use the DIR command first, to make sure the files you
copied really made it to their destination, before you delete the source
files. Suppose you give the command |nCOPY|n *.* A:\TEMP to copy all files
in the current directory to the |nTEMP|n directory in the root of the disk
in drive A:, and then DEL *.* to delete all the files in the current dir-
ectory now that you have copied them to A:\TEMP. But guess what? You
had the wrong disk in the A: drive, and it didn't have a directory named
|nTEMP|n on it. So now what you have is a huge file named |nTEMP|n on the disk
in drive A:, which is a concatenation of all those files that you thought
<page down> for more COPY
you just copied. Well they're pretty useless now (unless they were all
solid ASCII text) and your source files have already been deleted. Too
bad. If you had done a DIR A:\TEMP command before deleting the source
files, you would have seen that you had one huge file instead of the dir-
ectory that you thought you had, and you could have tried the |nCOPY|n again
before you deleted the source files.
The |nCOPY|n command won't copy files that are 0 bytes long, but XCOPY will.
If you want to change the date and time in a file's directory entry to
the |ncurrent|n date and time on your system clock, without changing the
file, use the command |nCOPY|n FILENAME /B + ,, and the two commas will take
the place of the second source file and the target file, the file will be
copied to itself, the /B ensures that all of the file will be copied, and
since DOS thinks it's doing concatenation, it updates the date and time
of the file's directory entry.
If you copy a file to a directory where there is already a file by the
same name, the file you're copying will be copied right over top of the
<page down> for more COPY
one that was already there, because DOS can only allow one file by a
certain name in each directory. So before you copy a file, make sure
you're not going to overwrite a file that already exists by that name
in the target |sdirectory|s! And this especially applies to the use of the
|nCOPY|n CON command! So many people will advise you to use that command to
write an AUTOEXEC.BAT or CONFIG.SYS file, but they forget to warn you
that if you already have a file by that name, this command'll erase the
old copy completely!
See the section on the RENAME command for some information about how the
meaning of wildcards differs slightly between the source side and the
target side of a command, when you're copying files to different names
than what they had before.
<page down> for The |nCTTY|n Command
The |TCTTY|T Command
I have no idea what that stands for, but I know what it does. It trans-
fers control of your system to some other device. Like if you have a
second monitor and keyboard connected to your COM1 port (also known as
|sAUX|s), then you could give the command |nCTTY|n AUX and output would go to the
second monitor, and input would be accepted from the second keyboard.
Then when you're ready to go back to the main monitor and keyboard, then
on the second keyboard you type |nCTTY|n CON and that puts things back to
normal.
Well the only use I've ever found for |nCTTY|n, since I don't have any other
monitors or |skeyboard|ss hooked up, is for cleaning up the screen display
during execution of a batch file. If you have a whole bunch of COPY
commands in a row in a batch file, you get a screen that looks like this
when you execute that batch file, even if ECHO is off:
1 file(s) copied
1 file(s) copied
1 file(s) copied
<page down> for more CTTY
Now who wants to look at a screen like that? Not I. If you're very
careful and make sure you don't forget the |nCTTY|n CON command at the end,
you can put |nCTTY|n NUL at the beginning of the list of COPY commands in the
batch file, like this:
|nCTTY|n NUL
COPY FILE1.TXT D:
COPY FILE2.TXT D:
(etc.)
|nCTTY|n CON
If you forget the |nCTTY|n CON at the end there, you'll be in big trouble.
Because your computer is no longer accepting any input from the keyboard.
You can't enter the |nCTTY|n CON command from the keyboard, because DOS is
only accepting input from the NUL device, which doesn't even exist. So
don't forget the |nCTTY|n CON command.
Another possible problem with |nCTTY|n NUL, is that it redirects not only
STanDard INput and STanDard OUTput, but also STanDard ERRor. So even the
error messages that would normally show on screen will go to the NUL de-
vice instead. You won't know if there have been any errors. So don't
<page down> for more CTTY
use |nCTTY|n NUL unless you're sure that the procedure that comes after that
command will never cause any errors. For example if you're copying files
to a RAMdisk whose letter is D:, you could use a command like IF NOT EX-
IST D:\NUL GOTO END to make sure that the RAMdisk was properly created,
before you use |nCTTY|n NUL and start copying. (See the section on EXIST for
details on that command.) And make sure that there's no possible way
that the batch file can possibly skip the |nCTTY|n CON command, such as be-
cause of a GOTO command or a syntax error.
Now if you ever need to use CON while you're in the middle of a |nCTTY|n NUL
section of a batch file, you don't have to do |nCTTY|n CON then do your stuff
then do |nCTTY|n NUL again. For example, if you need to use a PAUSE command,
you can do it like this:
ECHO Don't even think about using Ctrl-C or Ctrl-Break > CON
ECHO Strike any key to continue. . . . > CON
PAUSE < CON
This method uses redirection to send a message to the screen even though
output has been redirected to NUL, and the third line will accept a key-
stroke from the keyboard even though input has been redirected to NUL.
<page down> for more CTTY
Now if a body were to type the <Ctrl-C> or <Ctrl-Break> combination while
PAUSE is waiting for a keystroke, that would break out of the batch file
so that the |nCTTY|n CON command would not get executed. There's not a thing
you can do when that happens, except reboot. Because the NUL device is
never going to send the command |nCTTY|n CON to DOS, and that's the only
place DOS is accepting input from while a |nCTTY|n NUL command is in effect.
And don't be thinking that you can use the command BREAK OFF to make it
impossible for a user to press <Ctrl-Break>. That command doesn't turn
break checking off, it only makes it happen less often!
One more problem with this command, is that it only works on STDIN, STD-
OUT, and STDERR. That means STanDard INput, STanDard OUTput, and STanD-
ard ERRor. Those are the normal methods that DOS uses to communicate
with the CON devices (monitor and |skeyboard|s). Well there are many pro-
grams that read directly from the keyboard and/or write directly to the
video memory, and those programs will continue to use your normal CON de-
vice rather than NUL or AUX or whatever you had redirected it to using
the |nCTTY|n command. Because these programs are rude and bypass DOS to talk
directly to the keyboard and video adapter.
<page down> for The |nDATE|n and |nTIME|n Commands
The |TDATE|T and |TTIME|T Commands
These commands are pretty straightforward. If you enter the |nDATE|n command
with no parameters, its output will look about like this:
|nCurrent|n date is Wed 06-19-1991
Enter new date (mm-dd-yy): _
And it sits there waiting for you to either tell it the correct date, or
hit the <Enter> key to accept the date that is already there. You can
also enter the command with a date, as in |nDATE|n 06-19-91, and that will
just set the date and immediately give you a new prompt.
If you enter the |nTIME|n command with no parameters, here's the display:
|nCurrent|n time is 5:32:34.54p
Enter new time: _
You can also enter the new time right on the command line, as in |nTIME|n
5:32p or |nTIME|n 17:32. In most DOS versions, you can use a period instead
of a colon to divide hours from minutes. That's easier than messing with
the <Shift> key to type a colon. If you have DOS version 3.3 or earlier,
you're on a 24-hour clock like the military uses, instead of being able
<page down> for more DATE and TIME
to use a or p for a.m. or p.m. So if it is after noon, you add 12 hours
to the time. For example, 6 p.m. is 18:00 on a 24-hour clock.
If your computer doesn't have an |ninternal|n battery-backed clock, then you
need to have the |nDATE|n and |nTIME|n commands in your AUTOEXEC.BAT file so that
you'll have a chance to set the date and time in DOS's system clock each
time you reboot. Otherwise your system clock will be reset to 01-01-80
and 12:00 or something like that. Now whatever values are in DOS's sys-
tem clock (the name of which is |sCLOCK$|s) are the values that will be put
into the directory entries of every file that you update, and if the dir-
ectory entries get the wrong values, then an incremental BACKUP will act
on the wrong files. That's just one of the very important reasons for
keeping the right date and time in the system clock. So without a bat-
tery-backed clock, regardless of what a pain in the neck it is, you real-
ly do need to have these two commands in your AUTOEXEC.BAT file.
If you boot from a disk that doesn't have an AUTOEXEC.BAT file on it, or
if that file is not in the root directory where DOS knows how to find it,
then DOS will automatically execute the |nDATE|n and |nTIME|n commands when it's
<page down> for more DATE and TIME
done |sboot|sing up. If you do have an AUTOEXEC.BAT file, then DOS will only
execute these two commands if they are included in that file.
If you have DOS version 3.3 or later, and a hardware clock whose memory
address is the same as that used on true IBM brand computers, setting the
date or the time will automatically update the battery-backed hardware
clock so that the values will still be correct the next time you boot the
computer. If you have an earlier DOS version, then you have a command
file somewhere, that came with your computer, that allows you to change
the date and time that's stored in the hardware clock, because DOS won't
do it for you. Also it could be just a part of your CMOS setup, if you
don't have any command file for that purpose. Of course, ignore this
paragraph if you don't even have a hardware clock.
If you want to display the date or time without DOS stopping to wait for
you to press <Enter> or enter a new value, it can be done.
VER || |nDATE|n
will usually do it. That's because the VER command sends a carriage re-
turn (the <Enter> key) before it sends the version number so the carriage
<page down> for more DATE and TIME
return is the first piece of output that will be piped as input to the
|nDATE|n command, and since the |nDATE|n command only wants one piece of input in
the first place, the rest of |sVER|s's output won't affect anything. The
carriage return will go to the |nDATE|n command, which will have the same ef-
fect as if you had hit the <Enter> key from the keyboard. (See also
redirection.)
A similar method can be used to enter the |ncurrent|n date or time into an
environment variable for use in a batch file. You'll need to write two
batch files to make this work. You might call the first one DATEVAR.BAT:
VER || |nDATE|n > HELLO.BAT
HELLO
And the second batch file has to be named |nCURRENT|n.BAT:
SET DATE=%4
Now what happens is that the first command in DATEVAR.BAT uses the same
method as above to display the |ncurrent|n date on the screen without wait-
ing for any input. Only this time, instead of the display going to the
screen, a file named HELLO.BAT is created which contains the output of
the |nDATE|n command. The next line of DATEVAR.BAT runs HELLO.BAT:
<page down> for more DATE and TIME
|nCurrent|n date is Wed 06-19-1991
Which runs |nCURRENT|n.BAT with "date" as %1 and "is" as %2 and "Wed" as %3
and "06-19-1991" as %4. So the command inside |nCURRENT|n.BAT sets an envir-
ment variable named |nDATE|n, equal to the |ncurrent|n date at the time this ser-
ies of batch files was executed. (See also redirection and replaceable
parameters.)
If you want to have the |ncurrent|n time displayed as part of your prompt,
can use the $t prompt metacharacter to do that, but it will show you a
time like 17:15:43.72 and you don't want to see that, right? But there
is also a $h metacharacter which is the <Backspace>. So if you used the
command PROMPT $t$h$h$h$h$h$h$g, that would give you the time, and six
backspaces, and the > symbol, so it would look like 17:15> instead of
that ugly one that included the seconds and hundredths of seconds. And
you can also use the $d prompt metacharacter, to give you the date. When
you have the time displayed in the prompt, it doesn't get updated contin-
ually. Whatever it says is what it's going to keep on saying, until the
next time you hit the <Enter> key and a new, updated prompt is displayed.
<page down> for The |nDEL|n and |nERASE|n Commands
The |TDEL|T and |TERASE|T Commands
These commands are interchangeable. They are used to permanently remove
any file from any disk. Ok, there are utilities such as PC Tools that
can undelete a file, and in DOS version 5.0 there is even an UNDELETE
command. So deletion or erasure isn't always permanent. If you realize
right away that you made a mistake, you can use one of those utilities,
or if you have DOS 5.0 you can use the UNDELETE command. But if you do
not realize that you deleted the wrong file, until you or some program
has written some information to the disk, then maybe that information got
written right on top of where that deleted file was, and there's no way
to get that file back then! So you should always act like |nDEL|n and |nERASE|n
are permanent even though that's not exactly true.
The syntax is really easy. |nDEL|n FILENAME.EXT or |nERASE|n FILENAME.EXT is all
there is to it. DOS version 4.0 or later adds a /P switch, which causes
DOS to stop and ask if you're sure. This is useful when you're deleting
a group of files by using wildcards, because DOS will name each file that
it's about to delete, and if there was one that you didn't want to delete
<page down> for more DEL and ERASE
you can say no.
If you have DOS version 4.0 or later you should always use the /P switch
if you're using wildcards. For earlier versions, you should first use
the DIR command with the wildcard specification you're planning to use,
and it will show you the files that fit that wildcard spec. If those are
indeed the files that you want to delete, then just type |nDEL|n and hit the
<F3> key which will copy the wildcard specification that you'd used from
the template (DOS's |nmemory|n of the last command you entered) onto the cur-
rent command line and you can execute the command without a chance of de-
leting the wrong files. (See also editing keys.)
You can also use this command to delete all the files in a directory.
For recent versions of DOS, you just use the directory name in place of
the filename. For earlier versions, you use the *.* wildcard specifica-
tion. If your current directory is C:\ and you want to delete all the
files in C:\WP\LTRS you can just enter the command |nERASE|n WP\LTRS or |nERASE|n
WP\LTRS\*.* and DOS will say "Are you sure?" and you say "Y" and all
those files are gone. DOS always asks if you're sure if you try to del-
<page down> for more DEL and ERASE
ete a whole directory worth of files all at once. If you want to remove
the directory after you have removed all the files from it, use the RMDIR
command.
There are a couple of ways to get around that question, though. Don't
ever use this method without specifying the complete |spath|sname of the
files in question, because you might accidentally erase all the wrong
files, but here it is:
ECHO Y || |nDEL|n C:\WP\LTRS\*.*
The ECHO command sends the Y and a carriage return (the <Enter> key) to
the |nDEL|n command by means of redirection using the || symbol, so when DOS
asks you "Are you sure?" it finds that the "Y" is already waiting for it.
Another way is FOR %%a IN (C:\WP\LTRS\*.*) DO |nDEL|n %%a. That method will
work without even asking the question, because DOS won't realize that you
have asked it to delete the whole directory at once. It thinks it's del-
eting one file at a time.
Just don't ever forget that if DOS asks you "Are you sure?" after you en-
<page down> for more DEL and ERASE
ter a |nDEL|n or |nERASE|n command, that it's trying to tell you that it's about
to delete every file from some directory or another. If that's not what
you had in mind, then say no and take another look at the command you had
entered.
The |nDEL|n and |nERASE|n commands don't actually do a thing to the data in the
files that they delete. All they do is zero out the first bytes of the
directory and FAT entries for the files, so that DOS doesn't know they're
there anymore. The files are still on the disk, it's just that DOS can't
find them. That's why it is possible to UNDELETE them, until such time
as DOS uses that particular area of disk space to store some other file,
which overwrites the old deleted file and makes it totally unrecoverable!
<page down> for The |nDIR|n Command
The |TDIR|T Command
This command is used to display a DIRectory listing on your monitor. A
directory listing includes the name, extension, size, and date and time
of last modification, for each file listed. It also tells the volume
label of the disk, the name of the directory being listed, the number of
files and subdirectories displayed, and the free space left on the disk.
The |nDIR|n listing does not include files which have their H or S attributes
set to on, but it does work on files with R and A attributes.
You can display the directory listing for all the files in the current
directory, by giving the command |nDIR|n all by itself, with no parameters.
You can see the listing for all the files in some other directory by in-
cluding that |sdirectory|s's |spath|sname on the command line, as in |nDIR|n \DOS.
You can see the entries for the files on a different disk by including
that disk's drive letter as part of the command as in |nDIR|n A:. You can
see the names of only the files that have a .COM extension, by typing |nDIR|n
.COM, or just the files that start with the letter S by using |nDIR|n S*, or
<page down> for more DIR
just about anything you want to do by using the * and ? wildcards and/or
the name of the drive and/or directory whose listing you want to display.
(Notice those commas are punctuation in the sentence, not part of the
commands.) With the |nDIR|n command, you don't have to always include both
the filename and the extension of a group of files. I mean if you wanted
to do something like COPY all the files that have a .COM extension, you
would have to say *.COM but if you just want a directory listing of those
files, .COM will work. The same way with all the files that start with
S, to copy them you would have to say S*.* but to get a directory listing
of them, S* will work.
If you want to list the files that have no extension, |nDIR|n *. will do it.
If you just said |nDIR|n * then DOS would show you every file, in the speci-
fied directory, even those that have extensions. But since *. includes a
period, which is what separates filenames from their extensions, and then
it doesn't have anything after the period, that tells |nDIR|n to only show
files that have blank extensions (which includes directory names).
If you see a line that says <DIR> on it, in a directory listing, that is
<page down> for more DIR
a subdirectory entry. You can see what files are in that subdirectory by
issuing the command |nDIR|n NAME where NAME is the name of that subdirectory.
If you are displaying the listing for any directory other than the root
directory, the first two entries will be . <DIR> and .. <DIR>. See the
section on ". and .." for an explanation of those lines.
Remember that if you're looking for a particular file, it's a lot easier
to issue the command |nDIR|n FILENAME.EXT or |nDIR|n FILE*.* than it is to just
use the command |nDIR|n and scan all the filenames yourself looking for that
one file. Let DOS do the work for you.
Although DOS displays the filename, and then one or more blank spaces,
and then the extension, that's not the format you want to use when you're
trying to do something with a file. When you use a filename in a com-
mand, you type the filename, then no spaces, then the period, then the
extension. That's the only way you'll get anything done in DOS, even if
that's not the way DOS displays the directory listing. Really, though,
it is more convenient the way DOS displays it. It's just a lot easier to
read a directory listing like that. I've seen some file management util-
<page down> for more DIR
ities that display directory listings the way they have to be typed, and
they're really hard to read. Here's the difference:
How |nDIR|n Displays Them: How You Have to Type Them:
COMMAND COM |nCOMMAND.COM|n
AUTOEXEC BAT |nAUTOEXEC.BAT|n
CONFIG SYS |nCONFIG.SYS|n
DISKCOPY COM DISKCOPY.COM
|nFORMAT|n COM |nFORMAT|n.COM
ANSI SYS |nANSI.SYS|n
|nATTRIB|n EXE |nATTRIB|n.EXE
SMARTDRV SYS SMARTDRV.SYS
You can use redirection to send the output of the |nDIR|n command to the
printer, with |nDIR|n > PRN, or to a file, with |nDIR|n > FILE.EXT. Of course be
aware that if the file already exists, that command will delete every-
thing that's already in the file and put the directory listing in place
of it. If you want to add the directory listing to the end of a file
that already exists, use two > symbols, as in |nDIR|n >> FILE.EXT.
<page down> for more DIR
There are also two switches you can use with the |nDIR|n command, to modify
the command's operation a bit. The /P switch will cause the |nDIR|n command
to only show you one screenful of data and pause, and say "Press any key
to continue. . ." so that you can read what it says before it scrolls off
the screen. Then when you "Press any key", the next screenful of info is
displayed, etc.
Then there is the /W switch, which will give you a wide display. It will
not show you the size or date and time of the files, but will just dis-
play the filenames and extensions, in five columns so that if you have a
directory with a whole bunch of files in it, you might be able to see
them all on the screen at once.
If you have a directory that's got even more files than can be displayed
on one screen with the /W switch, you can use the /P and /W switches to-
gether, but you should seriously consider dividing those files into two
or more subdirectories instead of leaving them all in one directory.
If you do not have DOS version 5.0, then skip the rest of this section
<page down> for more DIR
except just to see what you're missing. One of the improvements in DOS
5.0 is a whole lot of options for the |nDIR|n command.
First of all, as well as the number of files listed and the free space
remaining on the disk, at the end of the directory listing, the total
number of bytes in the listed files is displayed. But remember, that's
not the amount of space those files use on the disk! It's just the total
of what's in the size column for the filenames displayed. The amount of
disk space used by those files will always be higher than that, because
of slack space.
Now the /W switch causes the filenames to be displayed in the form you
have to type them in, such as "CONFIG.SYS" instead of "CONFIG SYS" the
way it worked in earlier versions.
Let's have a chart of all the new DOS 5.0 |nDIR|n command switches now, be-
fore we get into serious explanations:
<page down> for more DIR
/A attributes /O order for sorting
A archive D date and time
D directory E extension
H hidden G group directories together
R read-only N name
S system S size
/B bare display--(dirname and) filename.ext only
/L lowercase dirnames and filenames
/P pause display on each page (all DOS versions)
/S subdirectories included
/W wide display--five columns (all DOS versions)
<page down> for more DIR
The /A switch will cause all filenames to be displayed, even those with
Hidden and System attributes. Or you could use /AH to display only the
files that have the Hidden attribute set to on. Or /A-A to show only the
filenames that do not have the A attribute. Or /AHR to show only the
files that have both the H and the R attributes. Or /A-S-D to show only
the files that have neither the S attribute nor the D (|sDirectory|s) attri-
bute. (That's right, along with the A, H, R, and S attributes, there is
also the D one, by which DOS tells files and directories apart, and this
can be accessed by DOS 5.0's new |nDIR|n command although the ATTRIB command
still doesn't work with it.) Or /AH-S to show only the files that have
the H attribute but not the S attribute.
The /O switch tells DOS what order you want the filenames sorted into
each time you see the directory listing. The sorting doesn't seem to
slow DOS down, so don't be shy about using this switch. Without this
switch, DOS displays the filenames in the order that their entries happen
to reside in the directory. With this switch you can display the direc-
tories in alphabetical order followed by the filenames in alpha order
(/O), or all the filenames and directory names mixed together in alpha
<page down> for more DIR
order (/ON), or reverse alpha order (/O-N), or all the files with no ex-
tensions followed by the directory names followed by the files that have
extensions sorted by extension (/OE), or the /OE display in reverse order
(/O-E), or all the files and directories mixed together and sorted by
date and time, from earlier to later (/OD), or from later to earlier
(/O-D), or all the directories in the order that they exist in the dir-
ectory followed by the filenames sorted by size starting with the small-
est ones (/OS), or the opposite of /OS--files sorted from largest to
smallest followed by the directories in directory order (/O-S), or final-
ly with the directories first in directory order followed by the files in
directory order (/OG), or files first followed by directories, all in
directory order (/O-G).
And of course you can use any combination of those /O switches. For ex-
ample, my favorite is /OGEN which means display the directories first,
followed by the filenames, and sort the file extensions in alpha order,
and within groups that have the same extension, sort those files by name.
(Having the same extension also means all the files that have no exten-
sion, and that includes directory names, so the directory names do also
<page down> for more DIR
get sorted in alpha order with that switch.) The switch combination
/OD-S would mean to sort the files by date and time, but within groups
that have the same date and time, sort those files by size, in reverse
order meaning from largest to smallest. (If you created all your direc-
tories at the same time, then they will appear together in a group in
this listing, but they won't be sorted in any particular order because
they all have a size of zero. But if you add an N to that switch com-
bination, making it /OD-SN, then the directory names, or any other group
of files that have matching dates, times, and sizes, will be sorted in
alpha order by name.)
The /S switch tells DOS to show you a directory listing for the specified
directory, followed by the listings for each and every subdirectory of
the specified directory, and every subdirectory of those subdirectories,
etc. If the specified directory is the root, then this will give you
every filename on the entire disk. If you combine this switch with a
filename or a wildcard specification, such as |nDIR|n *.BAT /S, you would
find every file on the disk that has the specified filename. Or if you
combine the /S with the /A, as in |nDIR|n /AH /S, that will show you every
<page down> for more DIR
file on the disk that has its Hidden attribute set to on.
The /B switch just gives you the filename-period-extension, with no vol-
ume label, no total number of bytes, no file sizes or dates, nothing ex-
cept the name, for all the files. If you combine it with the /A-D switch
to exclude the directory names, this is really useful for creating a
batch file or text file of all the files in a directory. |nDIR|n /B /A-D >
FILE.BAT will do it automatically. And if you add the /S switch, you'll
get all the specified files in the specified directory and all of its
subdirectories, and in that case the display will include the full |spath|s-
name for each file listed, so that you will know which file came from
what directory.
The /L switch will convert all the letters in the directory names and
filenames to lowercase.
Now another great feature of the DOS 5.0 |nDIR|n command, is that you can set
an environment variable called |TDIRCMD|T to tell DOS what switches you want
to use as the default. Normally the default is no switches, so if you
<page down> for more DIR
type |nDIR|n by itself, you get the display that you would get if you hadn't
entered any switches on the command line, right? Not anymore. If you
put the line SET |sDIRCMD|s=/OGEN /P into your AUTOEXEC.BAT file, then every
time you issue the |nDIR|n command, DOS will see in the environment that you
want to use the /OGEN and /P switches as the default, and you will get
that display every time. Now if you want to see, just this once, a dir-
ectory listing that is not sorted in any way, you can enter |nDIR|n /-O to
tell DOS that you want to temporarily ignore the /OGEN switch that you
have as your default in the DIRCMD environment variable. Of course like
any other environment variable, you can change it at any time by using
the SET command, or by editing the SET DIRCMD line in your AUTOEXEC.BAT
file and |sreboot|sing.
<page down> for |nDirectory|n Structure
|tDirectory|t Structure
A |ndirectory|n is like a Table of Contents that tells DOS where to find each
file on the disk. But a directory's size is set at the time a disk is
formatted, and cannot be enlarged. A |ndirectory|n on a hard drive can only
contain 512 entries. If you try to add another file to a |ndirectory|n that
is already full, you'll get a "|sdisk full|s" message. Well surely a hard
disk can hold more than 512 files?
Yes, it can, by putting subdirectory names in place of some of the file-
names in the |ndirectory|n. Subdirectories can have a number of files or
other subdirectories in them that is limited only by the amount of disk
space. A subdirectory listing is just like any other file; if the file
or the listing gets larger, it simply gets more space allocated to it.
Only the root |ndirectory|n is limited in size.
There are also other reasons for breaking the files up into groups in
subdirectories, rather than leaving them all in the root |ndirectory|n. For
one thing, if you actually had 512 files in your root |ndirectory|n, wouldn't
<page down> for more Directory
it be awfully hard to see what's there, with all those other filenames
getting in the way? Well it's hard for DOS to find a file that way, too.
DOS has to look through the entire |ndirectory|n listing, just like you do,
to find a file that you tell it to find. So it's best to keep large pro-
grams, that include many files, each in their own subdirectory, so that
both you and DOS can find them more quickly. MKDIR is the command that's
used to make directories and subdirectories.
The easiest way to visualize a |ndirectory|n structure, is like a file room.
The |troot|t |ndirectory|n (the main |ndirectory|n which covers the contents of the
entire disk) is like the fileroom. There are a bunch of file cabinets,
and a few separate file folders laying around that have not been placed
into the cabinets. The file cabinets are like subdirectories. Each sub-
|ndirectory|n can contain further subdirectories. These would be like the
drawers in the file cabinets. The drawers contain the files, just like
subdirectories contain files.
The |tcurrent|t |ndirectory|n is like whichever file cabinet or drawer DOS is
currently sitting in. To CHange the |ncurrent|n |nDIRectory|n, you use the com-
<page down> for more Directory
mand |TCHDIR|T, which can be abbreviated as |TCD|T. The current |ndirectory|n's also
called the |tdefault|t |ndirectory|n. A |ndefault|n just means whatever will be used
as parameters if the parameters are not specified.
The terms current and |ndefault|n can also apply to drives, and have about
the same meanings when they do. The current drive is the one whose drive
letter is shown in your prompt. But the current |ndirectory|n is not always
the same as the current drive. Each drive on your system has a current
|ndirectory|n at all times, even when that drive is not the current one. The
current |ndirectory|n, on a drive that is not current, is the |ndirectory|n that
would be current if that drive were made current. Unless you change the
current |ndirectory|n on a disk, it is the root |ndirectory|n. Each time you re-
boot your system, the root |ndirectory|n of each drive is the current one.
You can even use the |nCHDIR|n or |nCD|n command to change the current |ndirectory|n
on a drive other than the current one. For example, the |nCD|n C:\UTIL com-
mand will change the current |ndirectory|n on drive C: to \UTIL, whether C:
is the current drive or not. And the command |nCD|n with no parameters, will
show you what your current drive and |ndirectory|n are.
<page down> for more Directory
The way to change the current drive is quite simple. To make C: the cur-
rent drive, the command is just |TC|1:|T. To make A: the current drive, the
command |TA|1:|T would do it. There is no way in DOS to change the current
drive, and the current |ndirectory|n on that drive, all in one step. It
takes a C:, A:, etc. type of command as well as a CHDIR or CD command.
Another way to visualize a |ndirectory|n structure is like an upside-down
tree. The root |ndirectory|n is the trunk of the tree, the subdirectories
are the main branches, which can be further divided into smaller branch-
es, and the leaves are the files.
The |tparent|t of the current |ndirectory|n is the one that's next closer to the
root. If the current |ndirectory|n is a second-level subdirectory, then the
|nparent|n is the first-level subdirectory immediately above it in the upside
down tree. If the current |ndirectory|n is a first-level subdirectory, then
the |nparent|n is the root |ndirectory|n.
Referencing all these different drives and directories is not all that
difficult. To tell DOS what disk you're talking about, you use the drive
<page down> for more Directory
letter followed by a colon, as in C:. Then you start out with a back-
slash. A leading backslash always refers to the root |ndirectory|n of the
disk in question. Then you tell the subdirectory names, in order, start-
ing from the root, that lead to the file. Each subdirectory name is sep-
arated from the others by another backslash. Then you tell DOS the file-
name, a period, and the filename extension. |nDirectory|n names can be from
one to eight characters, and filenames are the same. The filename exten-
sion can be from zero to three characters. So, a full filename specific-
ation might look like this:
C:\WORD\LETTERS\FILENAME.EXT
Of course, it's best if you use really short words or abbreviations for
your |ndirectory|n names, because that will save you a whole lot of typing
over the years. Also, the PATH variable in the environment can only be
127 characters long, so if your |ndirectory|n names are long, you'll only be
able to fit a few of them into that variable.
DOS can tolerate a lot of shortcuts when dealing with file specifica-
tions. Anything that is the default can be left out. Suppose your cur-
<page down> for more Directory
rent drive is C: and the current |ndirectory|n on C: is \DOS. If you want
to refer to the file C:\UTIL\FOO.BAR, you can just say \UTIL\FOO.BAR
because if you leave out the drive letter, DOS will assume the current
drive, and in this case that's the drive you wanted anyway.
If your current drive is still C: and the current |ndirectory|n on the A:
drive is \GAMES and you want to reference the file A:\GAMES\PLAY.EXE,
then all you need to tell DOS is A:PLAY.EXE, because if you leave out the
|ndirectory|n, DOS will assume the current |ndirectory|n on the drive mentioned,
which is the right one. However, if you put a leading backslash in there
as in A:\PLAY.EXE, that wouldn't work because a leading backslash always
refers to the root |ndirectory|n, and PLAY.EXE is not in the root, it's in
the GAMES subdirectory which branches from the root.
Now suppose your current drive is still C: and drive C:'s current direc-
tory is still \DOS, and you want to refer to the file C:\DOS\GO.EXE, then
all you have to say is GO.EXE because C: and \DOS\ are both the |sdefault|ss.
Now let's say the current drive is C: and the current |ndirectory|n is \ (the
<page down> for more Directory
|sroot|s) and we want to tell DOS about that same file named C:\DOS\GO.EXE.
This time, we can still leave out the C: and also the leading \ because
those are the |sdefault|ss, and we can say DOS\GO.EXE.
If the current |ndirectory|n were \UTIL instead then we would have to include
the \ to remind DOS to start back up in the root |ndirectory|n again, then
look for the |ndirectory|n named DOS which is branching from a different spot
in the root.
Now how about the ". and .." directories that show up in every |ndirectory|n
listing except the |sroot|s? The .. entry stands for the parent |ndirectory|n.
Well suppose that the current drive is C: and the current |ndirectory|n is
\WORD\LETTERS\JOHN and we want to tell DOS to do something with a file in
a |ndirectory|n called C:\WORD\LETTERS\BILL. How do we do that? Well, we
have to first go up one level in the upside-down tree to LETTERS, and
then down one level to BILL. This will look pretty complicated at first,
but believe me, when you get used to it, it will be easier than typing
out the whole name, C:\WORD\LETTERS\BILL\FILENAME.EXT. Here's the short
way: ..\BILL\FILENAME.EXT. If it weren't for the .. symbol that takes
<page down> for more Directory
us up one level, then the shortest way to do it would have been \WORD\
LETTERS\BILL\FILENAME.EXT. So, even though the .. symbol will take a bit
of getting used to, it's worth it!
If you don't have a hard drive, you might think that you will never be
interested in directories. Guess again! Remember that the root direc-
tory of any disk is limited as to how many entries it can hold. For 360K
and 720K disks, that limit is 112 files, and for 1.2M and 1.44M disks, it
is 224. If you want to have more files than that on a disk, you have to
create a subdirectory on the disk to put the files into. Because al-
though the root |ndirectory|n is of a limited size, a subdirectory can con-
tain an unlimited number of files.
If you have more than 150 files in any |ndirectory|n, you should divide that
|ndirectory|n into subdirectories, so that DOS can find your files faster.
Now remember that even though it's easier for you to think of directories
in terms of file rooms, and upside-down trees, and stuff, in reality all
they are is files. They're just files which contain information about
<page down> for more Directory
other files. For example here's the |ndirectory|n entry for my AUTOEXEC.BAT:
41 55 54 4F 45 58 45 43 42 41 54 00 00 00 00 00
00 00 00 00 00 00 89 BE DC 16 6C 01 5D 03 00 00
The eleven bytes starting with 41, 55, 54, if you look those up in the
hexadecimal column of the ASCII chart, you'll find that they spell AUTO-
EXECBAT. (If the filename were less than eight letters long, there would
be one or more 20s between the name and extension of the file because 20
is hex for 32, which is the <Space>.) The next number is the attributes
byte, and since it says 00, you know that this file doesn't have any of
its attributes turned on. The four bytes 89, BE, DC, 16, are the date
and time of the most recent update to the file. The bytes 5D 03 are the
size of the file (the number of bytes in length). It's in the format
least-significant-byte-then-most-significant-byte, which is a really con-
fusing thing that computers do a lot, so really the file size is 035D in-
stead of 5D03, and 035D in hex is 861, so my AUTOEXEC.BAT file at that
time was 861 bytes long. Also in the |ndirectory|n entry is the number of
the first cluster of the file (where it's located on the disk). I sup-
pose that must be the bytes 6C 01 since those are the only non-zero bytes
left that aren't accounted for.
<page down> for more Directory
Well, a |ndirectory|n is just a file that holds an entry like that for each
file in the |ndirectory|n. A |ndirectory|n can be fragmented just like any other
file, and everything. The only thing that makes it different from any
other file, is that it has its D attribute turned on, so that DOS won't
let us treat it like a normal file. If you try to treat a |ndirectory|n
like a file, the result is often "|sAccess denied|s".
<page down> for The |n". and .."|n |nDirectory|n Entries
The |T". and .."|T Directory Entries
What on earth are these things? They appear at the top of every direc-
tory on my hard drive, except the root |sdirectory|s! What are they? The .
stands for the current directory, and the .. stands for the parent direc-
tory. You can use them as a form of shorthand. If you want to delete
every file in the current directory, you can type:
DEL *.*
or you can save typing those bothersome asterisks by typing:
DEL .
with the same results.
Suppose you're in a subdirectory of a subdirectory of (etc.) named
C:\WP\LETTERS\OCT1990\JOHN
and you want to change to the directory C:\WP\LETTERS\OCT1990. You can
either type
CD C:\WP\LETTERS\OCT1990
or, since .. stands for the parent directory of the current directory,
you can just type:
<page down> for more ". and .."
CD ..
with the same results! Won't that save a few thousand keystrokes per
year? Actually you don't even need the space in there, you could type
CD.. just as well.
And remember, when the DOS manual says that you can't remove a directory
until it is empty, it really means until it is empty of everything except
the . <DIR> and .. <DIR> entries! Don't ever try this:
DEL ..
to empty your directory in preparation for the RMDIR command, since what
that command will do is delete every file in the parent |sdirectory|s!
<page down> for The |nMKDIR|n Command
The |TMKDIR|T Command
This command is used to MaKe a new DIRectory. It can also be abbrevi-
ated as |TMD|T. The syntax is just |nMKDIR|n D:\DIR\NAME where D: is the drive
you want to put the new directory on, and |nDIR|n is the directory you want
to put the new directory under. Of course whatever parts of that command
are the |sdefault|ss, you can leave out. Some examples:
|nMKDIR|n C:\WORD\DOCS
would make a directory named DOCS underneath the WORD directory on the C:
drive.
|nMKDIR|n \WORD\DOCS
would make a directory named DOCS under the WORD directory on whatever
drive is current at the time.
|nMKDIR|n DOCS
would make a directory named DOCS under the current directory of the cur-
rent drive. If the current directory of the current drive were C:\WORD,
then the above three commands would all do the exact same thing.
|nMKDIR|n \DOCS
makes a directory named DOCS in the root directory of the current drive.
<page down> for more MKDIR
The longest |spath|sname you're allowed to have is 63 characters, so keep the
names short. For example, instead of a name like WORDPROC for your word
processor, use WP or WORD. That way, if your subdirectories end up very
deeply nested, you won't exceed the 63-character limit. Then again, you
probably won't want to make any subdirectories more than three or four
directories deep anyway.
When I say "the longest |spath|sname you're allowed", that has nothing to do
with the PATH command or the PATH environment variable. It means the
path that DOS follows to find one file. For example, you can have a sub-
directory named \DOS\UTIL\COMP\PK\PKZIP\PROGS\HOLD\TEMP\NOW, but you can
not have one with this name:
\DOS50\UTILITIES\COMPRESS\PKWARE\PKZIP\PROGRAMS\HOLDING\TEMPORAR\NOW
because that's longer than 63 characters!
<page down> for The |nRENAME|n Command
The |TRENAME|T Command
This command can be abbreviated as |TREN|T. In fact, many people don't even
realize that |nRENAME|n is a valid command; they think that |nREN|n is the whole
command, not its abbreviation.
It is used to give a file a different name from the name it has now. The
syntax is really easy.
|nRENAME|n D:\DIR\FILENAME.EXT FILENAME.EXT
Of course if the file is in the current directory of the current drive,
you can leave out the D:\DIR\ part. But you can't specify a |spath|sname for
the second filename, since you can't rename a file to a different place.
(For that you want the COPY command.)
You could also do something like rename all your .TXT files to have .DOC
extensions, all in one command, like this:
|nRENAME|n *.TXT *.DOC
Notice that wildcards on the target side of the equation have a different
meaning than wildcards on the source side. *.TXT means "every file that
<page down> for more RENAME
has a .TXT extension", but *.DOC means "the same first name as the source
files but with the extension .DOC". It won't do a thing to any files you
might already have with .DOC extensions. On the target side of the equa-
tion, wildcards just tell DOS to leave this part the same as it was on
the source side. So you could say |nRENAME|n CONFIG.SYS *.BAK to save typing
the word CONFIG twice. The same rule applies to any command that can use
wildcards on the target side of an equation.
If you try to rename a file to a name that some other file in the same
directory already has, you'll get a "Duplicate filename" error message.
You can't do that. Every file in a directory has to have its own unique
name. Either delete the file that already has that name, or COPY the
source file over top of it, or else choose a different name and try the
|nRENAME|n command again.
If you ever give a file a name with a <Space> in it, like FILE ONE.TXT,
you won't be able to do anything with that file. DOS doesn't allow spac-
es in filenames, so it won't let you delete or anything else, with such
an invalid name. But you can use a |nRENAME|n command with wildcards to fix
<page down> for more RENAME
that problem right up. |nRENAME|n FILE?ONE.TXT FILEONE.TXT will do it, be-
cause the ? wildcard stands for "any character in this position of the
filename" so that will take care of the <Space>. And now the file has a
valid name, so you can do whatever you want with it.
If you have a filename that's so badly garbled (probably because of mag-
netic damage to the directory entry) that the ? wildcard method won't
work, try this one:
XCOPY *.* NEWNAME /P
Now the /P switch will cause the XCOPY command to stop and ask you before
it copies each file, so you want to say no to all the files except the
damaged filename. The file with the damaged name will be copied to the
NEWNAME file, and then if you have DOS version 4 or later (don't even try
this if you don't have version 4, because the /P switch didn't exist for
the DEL command before that), you can use the same trick with DEL *.* /P
and say no to every file except the funky one. There, now the bad file-
name is gone and the file is still there, under the new name. If you
have more than one filename that's damaged like that, you have to start
up the XCOPY command again and this time say something like XCOPY *.*
<page down> for more RENAME
NEWFILE2 /P, because you won't be able to copy any other files to the
NEWNAME filename without overwriting the one you just created by that
same name. You'll have to specify another target filename.
You can rename all your external DOS commands (the ones that have disk
files, that are not stored inside the COMMAND.COM file) to whatever names
you want them to have. You can |nRENAME|n |nFORMAT|n.COM FORM.COM to make it
shorter to type, or you can |nRENAME|n |nRECOVER|n.COM BAD.COM so you remember
not to use it. But if you do any renaming of commands, just remember if
any other program or batch file calls them, it won't be able to find them
under the new names, because it's still looking for the old names. For
batch files, that's easy to fix; just edit the file and replace the old
command name with the name that you changed it to. Another reason this
can give you trouble, is that if you go over to a friend's house to help
him with his computer, and you go to format a disk and you type FORM A:
because that's what you're used to on your computer, well of course your
friend's FORMAT command is still named |nFORMAT|n.COM and your friend's going
to think you're not as smart as you think you are, because you'll get the
"|sBad command or filename|s" message.
<page down> for The |nRMDIR|n Command
The |TRMDIR|T Command
This command can also be abbreviated as |TRD|T. What it does, is to ReMove
any completely empty DIRectory. Before you can remove a directory, you
must remove all subdirectories from it (except the ". and .." entries),
as well as all the files.
The main problem with removing directories is that sometimes a directory
will contain files which have their Hidden, System, or Read-only attrib-
utes turned on. These files must first be deleted, but in order to del-
ete them, those attributes must be removed with the ATTRIB command.
Another problem with removing directories is that you cannot remove the
current directory. You must change to a different directory first, using
the CHDIR command.
See the section on the MKDIR command for the syntax of this one, since it
is just the same.
<page down> for The |nTRUENAME|n Command
The |TTRUENAME|T Command
This is an undocumented command, which means two things. First, it means
that it's not mentioned in the manuals. Second, it means that Microsoft
is not promising to keep supporting this feature in later DOS versions.
They might leave it in, or they might not. And it could, possibly, also
mean that the command doesn't always work right.
Well the command made its first appearance in DOS version 4, and its pur-
pose is, as its name implies, to tell you the actual name of a drive or
directory that is currently being disguised as some different drive or
directory, via the ASSIGN, JOIN, or SUBST commands.
For example, if you have used the SUBST command to pretend that the dir-
ectory D:\WORD\DOCS is the E: drive, then if you say |nTRUENAME|n E: it will
tell you D:\WORD\DOCS. You can also use this command with no parameters,
and it will tell you the true name of the current drive and directory, or
with a drive and |spath|sname, or with a filename, or whatever.
<page down> for The |nTYPE|n Command
The |TTYPE|T Command
This command is pretty much straightforward. It just types a disk file
to the screen where you can look at it. Or you can use it with output
redirection to send a copy of the file to your printer, or to a different
filename.
If the file is so long that it won't all fit on the screen at once, you
can stop the display from scrolling with the <Ctrl-S> keystroke combin-
ation, or the <Pause> key if you have one. Or you can use the MORE fil-
ter with redirection, or you can just use the MORE command instead of the
|nTYPE|n command if you're really careful about using the < symbol instead of
the > symbol!
One big problem with the |nTYPE|n command is that if you use it on a file
that has a ^Z (End-of-File) character inside it, |nTYPE|n will think that's
the end of the file, and won't display another byte of it. So if you
think that the file concatenation you just tried didn't work, it could be
that it worked just fine, only one of the first files in the concatena-
<page down> for more TYPE
tion had a ^Z at the end of it, so the |nTYPE|n command won't display the
other files that you concatenated onto the end of that one. They're
there, but you just can't see them with the |nTYPE|n command. You can see
them, though, with the command COPY /B FILENAME.EXT CON because the COPY
command with the /B switch will look in the file's directory entry and
see how many bytes long the file is, and copy all those bytes without
paying any attention to whether there are any ^Z characters in there.
Most .COM and .EXE files have ^Z (End-of-File) characters and ^G (Bell)
characters in them, so if you use the |nTYPE|n command on one of these, you
will hear a beep each time you reach a ^G character, and then the first
time you reach a ^Z character, the |nTYPE|n command will just stop and give
you back your DOS prompt.
Another use for the |nTYPE|n command is if you have a batch file where you'd
like to display a bunch of lines of messages to the screen all at once
from within that batch file. You could use a whole bunch of ECHO com-
mands, but that would be really slow since DOS reads each line of a batch
file from the disk, executes that command, reads the next line, etc. A
<page down> for more TYPE
faster way would be to make an ASCII file that contains just those mess-
ages that you want displayed, and perhaps name that file MESSAGES.TXT and
put it in your BELFRY directory (because that's where .BATs belong) and
then instead of putting all those ECHO commands into the batch file, just
put the command |nTYPE|n C:\BELFRY\MESSAGES.TXT in there instead. But then
if you give a copy of that batch file to a friend, don't forget to give
him the MESSAGES.TXT file too.
Anyway, the syntax for this command is just about as simple as it could
be, just the word |nTYPE|n followed by the filename and extension of the file
you want to display on your screen. And of course if the file is not in
the current directory of the current drive, then you tell DOS where it is
by including the entire |spath|sname for the file. Some examples:
|nTYPE|n CONFIG.SYS
|nTYPE|n A:|nCONFIG.SYS|n
|nTYPE|n C:\CONFIG.SYS
|nTYPE|n C:\DOS\BAK\CONFIG.BAK
The worst thing about the |nTYPE|n command is that it only goes one way. I
<page down> for more TYPE
mean if you want to go back and look at an earlier part of the file that
has already scrolled off the screen, you have to BREAK out of the command
with the <Ctrl-C> keystroke combination, and use the <F3> key to repeat
the same |nTYPE|n command again, and start over from the beginning. There
are lots of little public domain utilities such as BROWSE.COM, that you
can download from your local BBS, that let you use the <PageUp> and
<PageDn> keys to go to whatever part of the file you want to look at.
<page down> for The |nVER|n Command
The |TVER|T Command
This command is super simple to explain, but then again it doesn't do
anything useful, either. It just tells DOS to show you the name and num-
ber of the DOS version you're running. It might look like this:
C:\>VER
MS-DOS Version 5.00
And if you have version 5, there is an undocumented switch, /R. Here is
its output:
C:\>VER /R
MS-DOS Version 5.00
Revision A
DOS is in HMA
And that does mean the version that's in memory, that you |sboot|sed the com-
puter with, not just whatever version is installed on the current drive
or anything.
<page down> for The |nVERIFY|n Command
The |TVERIFY|T Command
This command, with no parameters, tells you whether DOS's write verifica-
tion flag is turned on or off. |nVERIFY|n ON will turn it on, and |nVERIFY|n OFF
will turn it off. Off is the default so if you want to leave it off, you
don't have to do anything with it. About the only time you want to turn
|nVERIFY|n on is when you're making a BACKUP, or when you think your disk is
going bad or something. But remember to disable your disk cache, or else
|nVERIFY|n does no good, because DOS will be verifying the data in the cache,
and just think that it's the disk that it's verifying.
It doesn't even verify that the data written is the same as the data that
was supposed to be written. All it does is verify that the |nchecksum|n for
both is the same. A |tchecksum|t is sort of like this, highly simplified:
2 + 4 + 3 + 5 + 1 + 9 = 24
The problem with that is, there are lots of other strings of data that
will give the same |nchecksum|n result:
2 + 3 + 8 + 6 + 1 + 4 = 24
So just because two things have the same |nchecksum|n, doesn't mean that they
<page down> for more VERIFY
match!
The only real benefit of |nVERIFY|n is to verify that the copy of whatever
was just written can be read from the disk, meaning that it was not writ-
ten to a bad sector. The main thing it does is make everything work a
lot slower than normal. The |nVERIFY|n command does the same thing as the /V
switch with the COPY or XCOPY commands, only |nVERIFY|n does it all the time
instead of just when you use the /V switch, if you have |nVERIFY|n turned on.
It's just a lot more sensible to use COMP or FC instead of |nVERIFY|n to make
sure any important files were properly copied.
<page down> for The |nVOL|n Command
The |TVOL|T Command
This command isn't any more fun than VER. All it does is tell you the
volume label of a disk. Like this:
C:\>VOL C:
Volume in drive C is WHATEVER
Volume Serial Number is 16CB-74E4
You could get the same information and more, from the DIR, CHKDSK, or
LABEL commands.
Of course, if you have DOS version 3.3 or earlier, you won't have a ser-
ial number on your disks.
The volume label is stored as an entry in the root directory of the disk,
even though it doesn't take up any disk space. The CHKDSK command will
count it as a Hidden file, because CHKDSK doesn't understand the Volume
attributes, so it interprets them as Hidden attributes instead.
<page down> for Reserved DOS Devices
Reserved DOS |tDevice|1s|t
A device driver is a piece of software that tells DOS how to deal with
some |nexternal|n peripheral device that connects to the computer. Well DOS
already knows how to deal with a few peripheral devices, because it has
some built-in device drivers for those devices.
These devices that DOS automatically knows how to work with have their
very own special names, and you mustn't try to use those names for any-
thing else, such as filenames or anything. For example, if you tried to
use the command COPY FILE.TXT |nNUL|n.TXT to make a copy of FILE.TXT and call
it |nNUL|n.TXT, DOS would completely ignore the .TXT extension and use the
device |nNUL|n instead of the filename you thought you were using. DOS would
copy the FILE.TXT file to the |nNUL|n device, which means "nowhere", and you
would not end up having the intended copy of that file at all.
Why does the |TNUL|T device mean "nowhere"? Well, it just does. It is a
name for a device that doesn't really exist. What good is it? Plenty.
For one thing, if you want to check the integrity of a file that's sit-
<page down> for more Device|1s
ting on a disk that you think you might have damaged, you can copy the
file to the NUL device and if DOS gives an error message, then you know
the file has been damaged. If there's no error message then the copy was
successful, which means the file was readable. Of course you could al-
ways just copy the file to another disk or directory, but unless you wan-
ted an extra copy of it anyway, then you'll just have to delete the file
after the test. Using NUL as the COPY command's destination saves that
step.
If you get a message "|sSector not found|s" from some program, but it doesn't
give you any clue as to which file has the bad sector, you can just go
into that program's directory and type COPY *.* NUL and since DOS shows
you the name of each file as it begins copying it, then when the "Sector
not found" or "Read fault error" message comes, the filename that's list-
ed right before the error message, is the file that's got the bad sector
in it, and you can use the RECOVER command to mark that bad sector out in
the FAT so that DOS will never again put one of your files into that spot
on the disk. (Be sure to read my RECOVER chapter before you do that!)
<page down> for more Device|1s
The most common use for the NUL device is to make the execution of a
batch file cleaner. Suppose you have COPY commands in your AUTOEXEC.BAT
file that copy files to your RAMdisk. Well after each of those files are
copied, DOS shows the message "1 File(s) copied" on the screen. You
don't want to look at that every time you boot your computer, do you?
Well you could put > NUL at the end of each COPY command, and since the
"1 File(s) copied" message is sent to STanDard OUTput, the > symbol will
use redirection to send that message to the NUL device and you won't have
to look at it on the screen anymore.
The |TPRN|T device is just another name for |nLPT1|n.
|TAUX|T is another name for COM1.
|TLPT1|T is the first parallel port, or printer port. If you have a printer
hooked up to it, you can print out a file by typing COPY FILE.EXT |nLPT1|n or
COPY FILE.EXT |nPRN|n. If your printer is hooked up to a serial port in-
stead, you can use the MODE command, as in MODE |nLPT1|n = COM1 to redirect
everything that DOS sends to |nLPT1|n, to COM1 instead. Then you'll be able
<page down> for more Device|1s
to use the PRN device as if your printer was on LPT1.
|TCOM1|T is the first serial port, or communications port. Modems, printers,
and mice are three things that are very commonly connected to serial
ports. If your modem has gone offhook and you can't get it to hang up,
you can use the command ECHO ATH0 > |nCOM1|n if your modem is on |nCOM1|n, to
make it hang up. (If your modem is Hayes-compatible and uses the Hayes
AT command set, that is.)
What's the difference between a parallel port and a serial port? Oh, a
big difference! A serial port sends bits (eighths of a byte) of data in
a serial fashion, that is, one after another. Just one bit at a time. A
parallel port sends data through eight parallel wires, so that eight bits
(one byte) go through the port at a time. So it's pretty safe to assume
that a parallel port will send a certain amount of information eight
times as fast as a serial port will. But printers are just about the on-
ly things that are very commonly hooked up to parallel ports. Modems and
mice just can't use parallel ports, even though it would be nice if they
could because of the speed difference.
<page down> for more Device|1s
The |TCLOCK$|T device can't really be used for any purpose from the command
line or anything. It refers to the clock that DOS uses to keep track of
elapsed time. (This is not the same as any battery-backed clock you
might have installed on your system.) Whatever time this clock says is
the time that will be listed in a file's directory entry every time you
update it. The only reason you need to know the name of this device is
just so you never try to use that name for a filename, since it is a re-
served DOS device name.
Ok, I saved the best device for last. |TCON|T is the device that DOS uses
for STanDard INput (STDIN), STanDard OUTput (STDOUT), and STanDard ERRor
(STDERR). Unless there has been some redirection performed, then STDIN
is the keyboard and STDOUT is the monitor screen. STDERR is always the
monitor. There are a whole lot of things you can do with the |nCON|n device
name, such as COPY |nCON|n PRN to make your printer act sort of like a type-
writer, or COPY |nCON|n FILENAME to create an ASCII file without using a text
editor or anything.
A lot of books show the device names as |nCON|n: or PRN: or LPT1:, with the
<page down> for more Device|1s
colons after them, but they work just fine with or without the colons.
I think the colons are mostly used just to differentiate between device
names and filenames, so that you don't think they're referring to some
filename when they say CON:.
<page down> for |nCode Page|n Switching
|tCode Page|t Switching
|TCHCP|T, |TCOUNTRY|T, |TGRAFTABL|T, |TKEYB|T, KEYB??, |TNLSFUNC|T, DISPLAY.SYS, PRINTER.SYS,
and SELECT are all commands and |sdevice driver|ss that have almost no use
other than to enable |ncode page|n switching; ignore them. The files in your
DOS directory which have the extension .CPI are the tables that these
commands use. Ignore them too. The MODE command is also used for code
page switching, but at least it has useful functions as well.
Oh, ok, I'll at least tell you what |ncode page|n switching actually is. IBM
could have picked a much simpler name for this stuff. All it means is,
setting DOS up to be able to use characters like Ä and ö for foreign lan-
guage alphabets, instead of the alphabet that we use here in the good old
U. S. of A. The |ncode page|n used for plain old English is the default, so
you don't have to set up anything special to use it. But if you want to
type in a different language, then you need to set up its |ncode page|n, so
you can use those foreign-language characters. So that's what |ncode page|n
switching is all about.
For beginning of File 6, see Abort, Retry, Fail, Ignore
|tAUTOEXEC.BAT|t|fSIMPLY1|f
|TCLS|T|fSIMPLY1|f
|TFAT|T|fSIMPLY1|f
|tUNDELETE|t|fSIMPLY1|f
|tXCOPY|t|fSIMPLY1|f
|tBatch|t|fSIMPLY2|f
|TCALL|T|fSIMPLY2|f
|TECHO|T|fSIMPLY2|f
|TEXIST|T|fSIMPLY2|f
|TFOR|T|fSIMPLY2|f
|TGOTO|T|fSIMPLY2|f
|TIF|T|fSIMPLY2|f
|TMORE|T|fSIMPLY2|f
|TNOT|T|fSIMPLY2|f
|TPAUSE|T|fSIMPLY2|f
|tRedirection|t|fSIMPLY2|f
|TREM|T|fSIMPLY2|f
|TSHIFT|T|fSIMPLY2|f
|TTEMP|T|fSIMPLY2|f
|tBytes|t|fSIMPLY3|f
|tCache|t|fSIMPLY3|f
|TCMOS|T|fSIMPLY3|f
|tDEVICEHIGH|t|fSIMPLY3|f
|TDO|1S|T|fSIMPLY3|f
|tHMA|t|fSIMPLY3|f
|tLOADHIGH|t|fSIMPLY3|f
|tMemory|t|fSIMPLY3|f
|TMODE|T|fSIMPLY3|f
|tRAMdisk|t|fSIMPLY3|f
|TRECOVER|T|fSIMPLY3|f
|tSector not found|t|fSIMPLY3|f
|TSELECT|T|fSIMPLY3|f
|tsetup|t|fSIMPLY3|f
|TSUBST|T|fSIMPLY3|f
|tANSI.SYS|t|fSIMPLY4|f
|tbad sector|t|fSIMPLY4|f
|TBREAK|T|fSIMPLY4|f
|TBUFFERS|T|fSIMPLY4|f
|TCOMSPEC|T|fSIMPLY4|f
|tCONFIG.SYS|t|fSIMPLY4|f
|tDevice Driver|t|fSIMPLY4|f
|TDEVIC|1E|T|fSIMPLY4|f
|TDRIVPARM|T|fSIMPLY4|f
|tEnvironment|t|fSIMPLY4|f
|TFCBS|T|fSIMPLY4|f
|TFILES|T|fSIMPLY4|f
|tfloppy|t|fSIMPLY4|f
|TFORMAT|T|fSIMPLY4|f
|tIBMBIO.COM|t|fSIMPLY4|f
|tIBMDOS.COM|t|fSIMPLY4|f
|TINSTALL|T|fSIMPLY4|f
|tIO.SYS|t|fSIMPLY4|f
|TJOIN|T|fSIMPLY4|f
|TLABEL|T|fSIMPLY4|f
|TLASTDRIVE|T|fSIMPLY4|f
|tMSDOS.SYS|t|fSIMPLY4|f
|tPATH|t|fSIMPLY4|f
|tPROMPT|t|fSIMPLY4|f
|TSET|T|fSIMPLY4|f
|TSHELL|T|fSIMPLY4|f
|TSTACKS|T|fSIMPLY4|f
|TSWITCHAR|T|fSIMPLY4|f
|TSWITCHES|T|fSIMPLY4|f
|tvolume|t|fSIMPLY4|f
|t*.*|t|fSIMPLY6|f
|tAbort, Retry, Fail, Ignore|t|fSIMPLY6|f
|tASCII|t|fSIMPLY6|f
|TBBS|T|fSIMPLY6|f
|tbinary|t|fSIMPLY6|f
|tBoot|t|fSIMPLY6|f
|tBoo|1t Disk|t|fSIMPLY6|f
|tcluster|t|fSIMPLY6|f
|tdecimal|t|fSIMPLY6|f
|tdisk full|t|fSIMPLY6|f
|tDisks|t|fSIMPLY6|f
|thexadecimal|t|fSIMPLY6|f
|tKeyboard|t|fSIMPLY6|f
|tParameters|t|fSIMPLY6|f
|tpublic domain|t|fSIMPLY6|f
|tReboot|t|fSIMPLY6|f
|tReplaceable|t|fSIMPLY6|f
|tsector|t|fSIMPLY6|f
|tShareware|t|fSIMPLY6|f
|tslack space|t|fSIMPLY6|f
|tWildcards|t|fSIMPLY6|f
|tAccess denied|t|fSIMPLY7|f
|tArchive|t|fSIMPLY7|f
|TASSIGN|T|fSIMPLY7|f
|tAttributes|t|fSIMPLY7|f
|TATTRIB|T|fSIMPLY7|f
|TBACKUP|T|fSIMPLY7|f
|TCHKDSK|T|fSIMPLY7|f
|TCOMP|T|fSIMPLY7|f
|TDOSSHELL|T|fSIMPLY7|f
|tediting keys|t|fSIMPLY7|f
|TFC|T|fSIMPLY7|f
|tfragmented|t|fSIMPLY7|f
|TGWBASIC|T|fSIMPLY7|f
|tHidden|t|fSIMPLY7|f
|toverlay|t|fSIMPLY7|f
|TQBASIC|T|fSIMPLY7|f