We will now begin looking at some of the commands you need to master to be proficient at DOS. The starting point has to be the commands that are probably used the most in DOS, to prepare a disk and copy files. Please note that in this discussion we will not cover every possible use of these commands, or every possible switch or argument pertaining to them. For a complete look at these commands, you should look them up in the DOS Help System.
Format
Formatting a disk prepares it to receive data. An unformatted disk cannot be used until it has been formatted. Part of this formatting process is installing a file system. For DOS disks, that is FAT-12.
Disks come in various sizes and densities. The original IBM PC used 5 1/4 inch floppy disks that were really floppy. You could bend them, though they probably would not work afterwards. These first DOS disks could be formatted to hold 160K of data on one side of the disk. A later innovation called double-density allowed both sides of the disk to be formatted, which helped to bump up the total to 360K. The final refinement of the 5 1/4 inch disk, called high-density, pushed this all the way to a whopping 1.2MB. This was to be the final appearance of the 5 1/4 inch disk though, since a smaller type of floppy had appeared, the 3 1/2 inch disk.
1/2 inch disks are encased in a hard plastic shell, which occasionally
confuses people who wonder about the “floppy” part of the name. But
inside this plastic shell there is a thin, and very floppy, mylar disk. The
equivalent double-density and high-density values are 720K and 1.44 MB respectively for these disks. (For more detail on floppy disks sizes and structures, see the Wikipedia page here.) BTW, for trivia buffs, Toshiba introduced a 2.88MB floppy drive in the late 1980s, but it never caught on.
Unless you have a real antique, you will only encounter 3 1/2 inch disks in either the double-density (720K) and high-density (1.44MB) variety. Looking at the disk from the top, you will see a small rectangular cut-out on high-density disks that is not there on double-density disks. While there are
ways of forcing a double-density disk to format as a high-density disk, the
failure rate goes up dramatically. since floppy disks are already fairly unreliable, this does not seem like a risk worth taking when brand-new high-density disks can be had for 50 cents apiece (American).
The FORMAT command has the drive to be formatted as an argument, and has several switches. Note that you cannot format a hard drive if you have
booted into it. If you need to reformat your hard drive, you will need a boot
floppy disk with the FORMAT command on it to accomplish your task. Also, you must remember that FORMATTING DESTROYS ALL THE FILES ON THE DRIVE! You should only use this command if you are absolutely certain that you know what you are doing and do not need anything stored on that drive.
So, to format a floppy, you can issue the command:
C:\>format a:
This will format the floppy disk in the A: drive.
You can also make certain that the disk is formatted to a certain
size using the /F: switch.
C:\>format a: /f:720
This will format the floppy disk in the A: drive as a double-density
720K disk, even if it is a high-density disk capable of being formatted for
1.44MB. This can be handy if you want to make a backup copy of a double-density disk using DISKCOPY, but only have high-density blank disks available.
Finally, you can make a boot disk by formatting the disk using
the /S switch to copy the system files to the disk.
C:\>format a: /s
Formatting a hard drive
The FORMAT command can also be used to prepare a blank hard drive to have files written to it, including installing an Operating System. Note
that you cannot FORMAT the boot hard drive if you have booted into it. For this purpose, a boot floppy disk with the FORMAT command copied to it is required.
A:\>format c:
This will format the C: drive.
A:\>format c: /s
This will format the C: drive and copy the system files to it.
This is almost never required, since if you are installing DOS you might just
as well let the installation program handle the formatting as well.
Copy
The COPY command will, as the name implies, copy files from one place to another. Arguments are the file to be copied, and the file and path it will be copied to. Switches include /Y to prevent a prompt when a file is being overwritten, /-Y to require a prompt when a file is being overwritten, and /V to verify the contents of the copy.
C:\>copy myfile.txt a:\myfile.txt
This will copy the file myfile.txt from the working directory on C: to the root directory of the floppy disk in the A: drive.
C:\>copy myfile.txt c:\docs\myfile.txt /v
This will copy the file myfile.txt from the working directory on C: to the C:\docs\ directory and verify the contents of the file.
You can also use the COPY command to combine and append files.
C:\>copy myfile1.txt+myfile2.txt myfile3.txt
This will combine the two files myfile1.txt and myfile2.txt, and place them in a new file called myfile3.txt.
Diskcopy
This command is used to make an exact copy of a diskette. It cannot be used to clone a hard drive. Arguments are the disk drives being used, switches
include /V to verify the contents of the copy. This command was most often used to make backup copies of software on diskettes back in the days when software actually came on diskettes, but it can also be used to make duplicates of other disks.
C:\diskcopy a: b:
This would copy the contents of the diskette in the A: drive to the diskette in the B: drive. If the diskette in the B: drive had any data on it, that data is erased in the copying process. If the diskette in the A: drive was a bootable diskette with system files, the diskette in the B: drive will be as well.
If no second drive is specified, the same drive will be used for both disks, and you will be prompted to switch diskettes. Place the source diskette in the drive first, issue the DISKCOPY command, and all the disk’s contents will be copied into memory. You will then be prompted to insert the target diskette in the drive, and the contents held in memory will be copied to it.
C:\>diskcopy b: /v
This would use the B: floppy drive for both the source and the target diskette, and would verify the contents of the target disk after the
copying.
Xcopy
The XCOPY command is designed to copy entire directories, along with all of their sub-directories, and all of the files contained in those sub-directories. Arguments are the files/path to be copied andthe place to copy them to. Switchesinclude:
- /A – Copies only files that have been set as archive files (see the ATTRIB
command). The copied files will still be marked as archive files in BOTH the source and destination files. - /D:(date) – Copies only those files in the source directory that have been
changed on or LATER than the specified date. - /S – Copies all files in the current directory and in any subdirectory within it.
- /E – Copies subdirectories, even if they are empty. This option must be
used with the /S option also. - /V – Verifies the copies that are made.
This is a very powerful command, and very useful, particularly for backing
up directories on your hard drive, or even the entire hard drive. You can use the archive attribute to specify which files will or will not be copied based on file type, or you can use the file date to only copy files that have been altered after a certain date (for instance, since your last backup).
XCOPY is also useful in copying all of the files from one floppy disk to another in cases where the DISKCOPY command can not be used, such as when the disks are different types or different sizes. But note that in this case if the source diskette is bootable, the target diskette will not be.
C:\> xcopy c:\docs d:\backup\docs\ /s
This command will copy the entire contents of the directory C:\docs, including all subdirectories and their contents, except for any empty subdirectories, and place them on drive D: in the directory D:\backup\docs\. If you wanted to copy empty subdirectories as well you would use:
C:\> xcopy c:\docs d:\backup\docs\ /s /e