Showing posts with label file-commands-of-dos. Show all posts
Showing posts with label file-commands-of-dos. Show all posts

The FORMAT Command

To make a floppy or hard disk capable of storage, DOS creates tracks and sectors on a disk. This process of creating tracks and sectors on a disk is called formatting. To understand this concept better, assume that you have a long roll of blank paper. To make this roll of paper usable (for writing), it could be cut into pieces about a foot long, and then lines and page numbers could be put on every sheet. You could consider this to be the equivalent of formatting whereby the disk is made usable.

After formatting is complete, the disk is divided into tracks that are concentric circles. Tracks are further divided into portions called sectors. Data is stored on these sectors as magnetic patterns.

Each track and sector has a number. During formatting, DOS also checks for defective spots and displays the number of bad sectors on the screen.

Assume that you have bought a new floppy disk and want to copy some files from the C disk to this disk.

For this, you have to first format the diskette because a brand new diskette cannot be used for storing data. All new disks have to be formatted before data can be stored on them. However, some diskettes are pre-formatted by the manufacturer.

The command for formatting a floppy disk in the A drive is:

C> FORMAT A: <Enter>

After you issue this command, the following message appears:

C>FORMATA:

Insert new diskette for drive A:

And strike Enter when ready

At this point, you insert a blank, unformatted disk in drive A and press the <Enter> key to begin the format. When the format program has ended, the following message will be flashed on the screen:

Format another (Y/N)?

If you want to format another blank disk, you press Y (for yes) and insert another blank, unformatted disk in drive A. If you do not want to format another disk, you press N (for no) to end the format program.

Old disks that already contain data can also be formatted if data is not required and the disk is needed for usage. In this case, all the old data is lost after the formatting procedure is completed. This is usually done if an old disk has certain bad sectors and is needed for usage. The FORMAT command must be used with extreme caution. Any disk that you format will lose all the data that existed on it before the formatting operation.

It is very important that you specify the drive name while issuing this command. The proper syntax for this command is:

FORMAT<drive name>

Be careful when you use the FORMAT command and ensure that you enter the right drive name.

FORMAT is an external command. In order to execute this command, the DOS file FORMAT.COM must be present. In contrast, there will be no program file called DIR.COM to execute the DIR command.

F0RMAT.COM is usually available along with the DOS software.

If you wish to specify a volume label for your disk, you may do so with the FORMAT command. In this case, the N option may be used. A volume label helps in identifying the disk and can be up to 11 characters in length. The command to be issued to give a volume label to a floppy disk at the time of formatting is:

C>FORMAT A:/V <Enter>

Another option that can be used with the FORMAT command is /S. If you issue the command:

C:>FORMATA:/S <Enter>

The operating system files are transferred from the C disk to the A disk, and the disk will be formatted. Now this floppy disk can also be used to load DOS into the computer's memory. The system files cannot be copied using the COPY command. In order to use a floppy disk to load DOS, the disk has to be formatted using the/S option.

If the operating system software (DOS) is available on the hard disk, you are prompted to insert a DOS diskette in the A drive.

Displaying the Contents of a File - the TYPE Command

If a file PAYROLL.DAT exists in the current directory of your hard disk and you want to see its contents on the VDU, the command to do so is

C>TYPE PAYROLL.DAT <Enter>

You can also specify a path to DOS with the TYPE command. If the same file PAYROLL.DAT existed in the directory PAYMENT of the hard disk, the following command can be issued to display its contents:

C>TYPE C:\PAYMENT\PAYROLL.DAT <Enter>

If the file PAYROLL.DAT exists in the root directory of the A drive and you wished to display its contents, you have to specify the drive name before the file name. The command to do that is

C>TYPE A:PAYROLL.DAT <Enter>

Note: The Type command is useful for viewing text files.

Moving Files - the MOVE Command

The Move command allows you to move one or more files from one drive to another drive or from one directory to another directory. Assume that there is a file INTERNET.TXT under the directory INCOME on the hard disk that needs to be moved to a diskette. This can be done by issuing the following command:

C>MOVE C:\INCOME\INTERNET.TXT A: <Enter>

This command deletes the file physically from the hard disk and moves it to the target location.

Deleting Files - the DEL Command

You may discover that there are some files on the disk that you do not require anymore. Unwanted files occupy space on the disk. Therefore, it is desirable to remove such files. Assume that there is a file CON.BAK on the hard disk, which you do not require anymore and want to remove or delete. This can be done by issuing the following command:

C>DEL C:CON.BAK <Enter>

This command deletes the file CON.BAK from the hard disk. DOS does not, however, give any confirmation of deletion of this file. If you wish to delete a file from the A drive, you have to specify the drive A before the file name. For example:

C>DEL A:CONFIG.BAK <Enter>

You can also specify a path to DOS with the DEL command. If you wish to delete a file named LOCAL.3, which exists in the directory NETWORK on the C disk, the command you could give is

C>DEL C: \NETWORK\LOCAL.3 <Enter>

Renaming Files - the REN Command

Sometimes you may find that a name that you had given to a file initially is no longer suitable. If you wish to change the name, you need not copy it again under a different name. DOS allows the user to change the name of a file. This can be done by using the REN command. If you have a file named ZZZ.PIT and you now wish to rename it to LOAN.SUM, the command would be

C>REN ZZZ.PIT LOAN.SUM <Enter>

The file ZZZ.PIT will now exist under the name LOAN.SUM. Though the name has been changed, the contents of the file remain the same. A path can also be defined with the REN command. Let us assume that you wish to change the name of the file CALM that exists in the directory WEATHER on the C drive. The new name to be given is STORM. The command you could give

C>REN \WEATHER\CALM STORM <Enter>