Skip to main content This browser is no longer supported. Show Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. dir
In this articleDisplays a list of a directory's files and subdirectories. If used without parameters, this command displays the disk's volume label and serial number, followed by a list of directories and files on the disk (including their names and the date and time each was last modified). For files, this command displays the name extension and the size in bytes. This command also displays the total number of files and directories listed, their cumulative size, and the free space (in bytes) remaining on the disk. The dir command can also run from the Windows Recovery Console, using different parameters. For more information, see Windows Recovery Environment (WinRE). Syntaxdir [<drive>:][<path>][<filename>] [...] [/p] [/q] [/w] [/d] [/a[[:]<attributes>]][/o[[:]<sortorder>]] [/t[[:]<timefield>]] [/s] [/b] [/l] [/n] [/x] [/c] [/4] [/r]Parameters
Remarks
ExamplesTo display all directories one after the other, in alphabetical order, in wide format, and pausing after each screen, make sure that the root directory is the current directory, and then type: dir /s/w/o/pThe output lists the root directory, the subdirectories, and the files in the root directory, including extensions. This command also lists the subdirectory names and the file names in each subdirectory in the tree. To alter the preceding example so that dir displays the file names and extensions, but omits the directory names, type: dir /s/w/o/p/a:-dTo print a directory listing, type: When you specify prn, the directory list is sent to the printer that is attached to the LPT1 port. If your printer is attached to a different port, you must replace prn with the name of the correct port. You can also redirect output of the dir command to a file by replacing prn with a file name. You can also type a path. For example, to direct dir output to the file dir.doc in the Records directory, type: dir > \records\dir.docIf dir.doc does not exist, dir creates it, unless the Records directory does not exist. In that case, the following message appears: File creation errorTo display a list of all the file names with the .txt extension in all directories on drive C, type: dir c:\*.txt /w/o/s/pThe dir command displays, in wide format, an alphabetized list of the matching file names in each directory, and it pauses each time the screen fills until you press any key to continue. Additional References
FeedbackSubmit and view feedback for How do I change the root directory in Windows?Switch to the root directory of another drive, if desired, by typing the drive's letter followed by a colon and pressing “Enter.” For example, switch to the root directory of the D: drive by typing “D:” and pressing “Enter.”
How do I get to the root directory?To navigate into the root directory, use "cd /" To navigate to your home directory, use "cd" or "cd ~" To navigate up one directory level, use "cd .." To navigate to the previous directory (or back), use "cd -"
How do I get to root directory in CMD?cd\ - This command will take you to the root directory, regardless of your location.
Which DOS command is used to change a directory?CD (change directory) is a command used to switch directories in MS-DOS and the Windows command line.
|