Chapter 4
BATCH FILES
Executing
Several
Commands
Some
tasks
require
two or more commands. For example, when
preparing
a
disk
for information storage, you
must
format
the
disk
so you
can
write
to
it
(FORMAT command).
In
addition,
it
is a good
habit
to
immediately
check
the
directory
of
the
new
disk
for
errors
(CHKDSK
command).
The
Batch
File
You
can
put
a
command
sequence into a special file called a
batch file.
Then
you
can
execute
the
entire
sequence by
entering
the
name
of
the
batch
file.
To
create
a
batch
file, you
can
specify
the
complete
pathname
or
a filespec.
In
either
case, give
the
file
the
extension .bat.
When
you execute
the
file, however,
enter
the
filename
without
the
extension.
Below is a description of how to
use
the
COPY
command
to cre-
ate
a
batch
file.
(You
can
also
use
EDLIN; see
Part
3.)
Creating
a
Batch
File.
To
create
a file to perform a
command
sequence of FORMAT
and
CHKDSK,
type
this
at
the
system
prompt:
copy
con
prepdisk
.bat
[ENTER
I
This
command
tells MS-DOS to copy
the
information
entered
from
the
keyboard (console) into a
batch
file called prepdisk.bat.
Because
you
do
not specify otherwise, MS-DOS
creates
the
file
in
the
current
directory.
MS-DOS displays
the
cursor. Now you
can
type
the
commands
to
be included
in
the
file:
rem
Thls
prepares
and
checks
new
disks
[ENTERI
rem
i
tis
calle
d
Pre
p
dis
k .
bat
I
ENTER
I
for
ma t
B:
I
ENTER
I
pause
I
ENTER
I
c h k d s k
B:
I
ENTER
I
21