Directory Commands of DOS

Certain DOS commands facilitate the creation or removal of directories so that you can organize the hard disk or a diskette. They also allow moving from one directory to another and viewing the list of files on a disk, under the root directory as well as other directories. These commands are the directory commands of DOS.

Displaying a List of Files on the Disk - the DIR Command

As stated earlier, there may be many files on a disk. If you wish to know which files you have on a particular diskette or on the hard disk, you can ask DOS to display the list of files on the disk.

For example, if you wish to view the list of files on the hard disk, the command would be:

C>DIR C: <Enter>

C: signifies the C drive. Pressing the <Enter> key indicates the end of the command.

A sample execution of the DIR command is shown in Figure.

For the time, ignore the significance of the first three lines. Notice that from the fourth line onwards, each line has 5 columns. The columns are:

  1. Primary name
  2. Extension


  3. Hence, columns 1 and 2 give the complete file name. For example, C0MMAND.COM is a file name where COMMAND is the primary name and COM is the extension.

  4. Size of each file in bytes. Recall that one byte stores one character
  5. Date on which the file was either created or modified last
  6. Time at which the file was either created or modified last

A Sample DIR Display

A Sample DIR Display

If you wish to see the list of files on the diskette, i.e. in the A drive, the command will be:

C>DIR A: <Enter>

In the list of files shown in Figure, PERSONAL is a directory. <DIR> signifies a directory. Therefore, the root directory of the C drive contains, apart from various files, a directory named PERSONAL.

Let us assume the directory PERSONAL contains a subdirectory called ADDRESS. To view the contents of the subdirectory ADDRESS, the command will be:

C>DIR C:\PERSONAL\ADDRESS <Enter>

where \PERSONAL is the path to the subdirectory Address

Thus, you can specify path to DOS along with the DIR command. If you wish to see whether a file named MK_APTS exists under the subdirectory ADDRESS, you can issue the command:

C>DIR C:\PERSONAL\ADDRESS\MK_APTS<Enter>

If the file does not exist there, DOS will indicate to you that the file has not been found.

If the currently active directory is the subdirectory ADDRESS, then the entire path need not be defined to DOS. The following command would be sufficient:

C>DIR MK_APTS <Enter>

You can see that the currently active drive need not be specified either. However, if you wish to view directory contents in a drive or a directory other than the active one, the complete path must be defined to DOS. Otherwise, an error message will be displayed.

More on the DIR Command

If you have a large number of files on a disk and you issue the DIR command, the file names will scroll off the screen and only the last few names will be visible. In such cases, the DIR command that can be used is:

C>DIR C:/P <Enter>

This command lists the contents of the disk page-wise. Once the screen is full of file names, the following message will appear and the scrolling will stop.

Press any key to continue...

When a key is pressed, the next screen of file names will be displayed.

An alternative command that can be used if one wishes to view all the file names at the same time is:

C>DIR C:/W <Enter>

A Sample DIR/W Listing

A Sample DIR/W Listing

The DIR/W command lists the contents of the disk width-wise, i.e. five file names per line (refer Figure)

As is evident from the screen in Figure, details like the number of bytes occupied by each file, the date and the time of creation of each file are not displayed with the file names when the contents are listed width-wise.

DOS Commands

DOS allows you to perform various activities. For example, you can display a list of files or remove unwanted files, and so on. To perform these activities, you must give DOS certain instructions. These instructions are referred to as DOS commands.

At the command prompt, which is C> or A>, depending upon the active drive, you may enter any of the DOS commands. There are different commands for different activities. After you give the command, DOS carries out what it has been asked to perform. This is also referred to as the execution of DOS commands. DOS commands may be classified as directory commands and file commands.

Need for Directories

You are already aware that files are stored on external storage media. There could be many files on a disk, and this may pose a problem when a^particular file has to be located. Therefore, files must be organized in an orderly manner.

To understand this concept of file organization on a disk, let us take the example of a library. Figure shows the library layout.

You can see that the library has four floors and each floor has books belonging to a certain area of learning (arts, science, engineering, and so on). Each floor has been divided into a number of rooms, which contain books dealing with a specific subject within the area.

Thus, the school of arts has been divided into four sub-units. If you wish to locate a book on Indian history, you do not have to search through the entire library. You can go directly to the school of arts where you would find all books on history in the third room. This helps you locate the particular book you want much faster than if you were to search through the entire library, or even the entire first floor containing books pertaining to the school of arts. Since you know that the book on Indian history is likely to be in the History room, you would only have to look for ft there. Just like the books in a library are arranged in a structured manner, so should the files be arranged on a storage medium.

Library Floors and Rooms

Library Floors and Rooms

Organization of Files in Directories and Subdirectories

Let us assume that you have three files. One contains details like names, ages and addresses of all the employees in a firm, another contains details of salaries of the employees, and a third contains the details of loans given to the employees. All these files relate to the employees of the firm. Therefore, it would be desirable to put all these files together, under a single unit.

To enable the user to arrange files within units and sub-units, DOS provides structures called directories on a disk. Directories have names, just as the floors of the library in the earlier example.

Let us assume that you wish to keep three kinds of files on a disk: LETTERS files, EXPENCES files and INCOME files. Within the EXPENCES files, you wish to further classify the files as PERSONAL and OFFICIAL EXPENSE files. DOS helps you to create a structure as shown in Figure.

In the structure in Figure, the Letters directory is a subdirectory of the root directory. PERSONAL is the subdirectory of EXPENSES. EXPENCES can also be called the parent directory of the PERSONAL directory.

All files relating to a particular subject can be kept together under a directory. The root directory in DOS is denoted by a backslash (\)

The directory structure resembles an inverted tree where the main directory is the root; hence it is called the root directory.

Root Directory and Subdirectories

Root Directory and Subdirectories

File Referencing

Refer to the example of the library. To locate a book dealing with biology, you would have to go to the fourth room on the third floor. Similarly, in the case of the directory structure shown in Figure 1.4, to access the PERSONAL files, you would have to go to the subdirectory PERSONAL under the directory EXPENSES.

DOS allows the user to access files by moving from one directory to another. To begin with, the user is always located in the root directory.

While moving from one directory to another, certain rules have to be followed. Let us take an example.

You cannot go directly from the LETTERS directory to the EXPENSES directory. To go from LETTERS to EXPENSES, you will have to go to the root directory first and then proceed to EXPENSES. Similarly, to go from PERSONAL to OFFICIAL, you would first have to go to the parent directory EXPENSES and then proceed to OFFICIAL. In other words, when moving from one directory to another, you first have to go to the parent directory. However, you can go directly to the root directory from any subdirectory.

Besides the method of moving to different directories to access files, there is another method that ensures file access by defining a path to DOS.

Let us first understand the mechanism of path. Refer to the example of the library. If you do not want to go and get a book yourself, you ask a friend to do so and give him or her the required directions.

Similarly, you can provide DOS with a path to the target directory.

Suppose you wish to access a file from the PERSONAL directory. You would have to first refer to the root directory and then the EXPENSES directory.

To access a file called TRAVEL.EXP is the PERSONAL directory, you would have to specify the path as:

Path Referencing

Path Referencing

Here,

1 is the drive name.

2 is the root directory.

3 is the directory under the root directory, starting from which a file has to be accessed.

4 is the subdirectory under the directory mentioned in 3 (3 is the parent directory).

5 is the primary name of the fiJe to be accessed.

6 is the extension name of the file to be accessed.

This is the complete file reference that indicates that there is a subdirectory PERSONAL under a directory EXPENSES which is under the root directory, and the subdirectory PERSONAL contains a file named TRAVEL.EXP.

The '/' (backslash) is a convention that must be followed to enable DOS to trace the path. By specifying the first '/', DOS is automatically directed to go to the root directory from any directory. Thus, any path that is stated essentially starts from the root. The subsequent backslashes are to separate the various directories, subdirectories, and the file name that has been specified in the path.

The Bootstrap Procedure

Before we understand how DOS works, let us take a look at the different types pf machine and their specifications for DOS.

The difference between a PC, a PC-AT and a PC-XT is in the types of disk storage devices available. The two diskette drives on a PC are referred to as the A drive and the B drive. On a PC-XT, the diskette drive is referred to as the A drive and the hard disk drive is referred to as the C drive. On a PC-AT, the two diskette drives are referred to as the A drive and the B drive, and the hard disk drive is referred to as the C drive.

The hardware cannot function without the operating system. To be able to use the PC, PC-XT or the PC-AT, the operating system (DOS) software must always be present in the memory of the PC/PC-XT. The same is true for a PC-AT.

The core of the MS-DOS operating system is contained in three files, IO.SYS, MSDOS.SYS and C0MMAND.COM. These files are located in the first sector (also called boot sectoi) of the floppy or hard disk. After the system unit is switched on, a search is made for the DOS software on A drive. If it is not available there, it is searched for on the hard disk. If DOS is available on the hard disk, it is loaded automatically. So, if your PC-XT/PC-AT does not have DOS on its hard disk, ensure that it is available on a diskette and insert the disk into the A drive before you switch on the computer. This process wherein the computer locates the operating system and loads it into the memory is termed the Bootstrap procedure.

Note: A floppy or hard disk is divided into concentric circles called tracks. These tracks are further sub-divided into sectors. The boot sector is the first sector on the disk.

As soon as DOS is loaded, the following query appears on the VDU:

Current date is Tue 1-01-1997
Enter new date (mm-dd-yy):__

DOS expects you to enter the new date immediately after the colon (:), at the position of the cursor, which is a blinking, underscore-like symbol (_).

Enter the date in the specified format; mm stands for month, dd stands for date, and yy stands for year.

If you do not enter a new date, the displayed date will be treated as the current date, anii bbow

If you enter the date in any format other than the one specified, an error message will be displayed.

After entering the date, you press the or key. After this, the display on the VDU is as follows:

Current date is Tue 1-01-1997
Enter new date (mm-dd-yy): 1-03-1997
Current time is 0:01:50:12
Enter new time:__

Enter the new time using numbers, in the format hour:minutes:seconds. The seconds' entry is optional.

After entering the new time, you press the key. If DOS has been loaded from the hard disk, the display will be as follows:

Current date is Tue 1-01-1997
Enter new date (mm-dd-yy): 1-03-1997
Current time is 0:01:50:12
Enter new time: 10:45
C>_

Note that the control has been transferred to the C drive.

If DOS has been loaded from the diskette, the display will be as follows:

Current date is Tue 1-01-1997
Enter new date (mm-dd-yy) :l-03-1997
Current time is 0:01:50:12
Enter new time:10:45
A>_

Note that the control has been transferred to the A drive.

The command prompt is C> which appears when DOS has been loaded from the C drive. Similarly, A> is the command prompt which appears if DOS has been loaded from the diskette in the A drive.

Thus, the currently active disk drive can be identified from the prompt C> or A>.