MS-DOS DIRECTORY Command
MS-DOS DIRECTORY Command
In this tutorial, we will learn about the MS-DOS directory command, which is dir. The command displays the list of files and subfolders (subdirectories) in the current or specified directory.
MS-DOS Directory Command
The directory command displays the contents of the directory. It lists the files, subdirectories, and other information in a directory or folder, similar to a table of contents in a book.
Syntax
The basic syntax for the directory command is as follows:
\> dir [drive:][path][filename] [/A[:attributes]] options
Square brackets [ ] indicate optional parameters and : (colon) indicates that an additional value can be provided in the command.
Examples
This example will list all the files and subdirectories in the current directory. The steps to follow are:
- Open the command prompt and issue the following command.
- At the command prompt type, dir and press ENTER key.
\> dir
This directory will list the following information:
- Date and time the file was last updated.
- <DIR> to indicate whether the entry is a directory.
- Size of each file
- File name or directory name with the file extension
The list of files will scroll up and off the screen. The summary of the files and directories is displayed at the end of the listing. A line that shows the number of bytes free on the hard drive.
Search Files
To search for files with a particular pattern, you can use wildcards. For example,
\> dir *.exe
lists the executable files in the current directory.
To list files with a specific pattern. For example, to list files and sub-directories that start with the letter ‘w’.
\> dir w*
Pagination
The /p option with the dir command in MS-DOS pauses after each screenful of information. It allows you to review the contents page by page and press a key (often the spacebar) to continue viewing the next page.
\> dir /p
Wide list format
The /w option is used to display a wide list format. It displays the files and directories in a more compact, horizontally aligned format, making it easy for more entries on a single line.
/> dir /w
—
More information on the MS-DOS commands:
https://en.wikipedia.org/wiki/List_of_DOS_commands