Learn about the DIR . command [Directory] in CMD [Command Prompt]

Comeinand DIR stands for the word Directory. This is the command that allows us to view and track files, as well as folders in the Folder you point to.

Yes, and in this article we will learn more about the DIR command on Windows operating system. About all DIR commands as well as how to use this DIR instruction..

#first. The Ultimate Guide to the Directory . command

For example, when I run a DIR command, we have the following entries:

  • Red: Display Date, Month, Year of File or Folder (including creating, copying or moving files or folders into this folder).
  • Orange: The time the File or Folder appeared in the folder.
  • Blue: Marking tells us it is a folder (Folder).
  • Purple: Size of the file.
  • Green: File or Folder Name.
  • Yellow: Hard drive name and number.

tim-hieu-velenh-dir-directory-in-cmd (1)

  • White: Number of files and subfolders in Folder. Also list the available and free space of the hard drive containing this folder.

tim-hieu-velenh-dir-directory-in-cmd (2)

Specific examples: Now I want to see files and folders in Folder Server at the drive D I will have 2 ways as follows:

Method 1: For example, here I want to access the directory Server in the drive D then I will use the following command (after each command you press Enter Please):

cd Server

Read more articles: How to use CMD (Command Prompt) [đầy đủ & dễ hiểu]

tim-hieu-velenh-dir-directory-in-cmd (3)

Method 2: Enter command dir -path-of-directory. Specifically here is the command dir D:Server

tim-hieu-velenh-dir-directory-in-cmd (4)

So some of you will ask: In what cases are the above two methods used? Then for me, the first way will be used when you do a lot of things with that folder.

See more:  [Tut] How to Recovery Laptop with built-in copyright

For example, after using the dir command, you can use more commands for the files or subdirectories in it.

The second way is more convenient to just copy the path to the command, but it will be very inconvenient if you want to use other commands for that file or directory. You can flexibly use the two methods above.

#2. Advanced Commands in Directory

You can categorize files or folders by attributes. Has the following properties:

  • Directories (d): Subfolders only.
  • Read-only files (r): Only files or folders are read-only.
  • Hidden files (H): Only files or folders are hidden.
  • System files (S): Only system files or folders.
  • Not Directories (-d): Does not list subdirectories.
  • Not Read-only files (-r): Do not list files or directories as read-only.
  • Not Hidden files (-H): Do not list hidden files or folders.
  • Not System files (-S): Does not list system files or folders.

2.1. The way to manage files in the Folder is as follows, here is the general formula:

get out:“attribute in parentheses” “File path (if not already pointing to directory)”


For example: I want to filter Folder Server If you only display directories, you will use the following command:

get out:d “D:Server” (Because I pointed Command Prompt to the folder Server so no need to add path D:Server again).

=> As you have seen, CMD only displays directories and ignores all files in the directory.

tim-hieu-velenh-dir-directory-in-cmd (5)

Note: Attributes can be combined. For example, if you want to filter only hidden folders, use the following command:

See more:  5 ways to restart File Explorer on Windows 10/8/7

get out:dh (d: show folder, H: show hidden files and folders).

tim-hieu-velenh-dir-directory-in-cmd (6)

As you can see, in the folder Server I only have subfolders dungeon5 has hidden attribute so dir only show each folder above.

Not only that, the command dir also allows us to see the owner of a file or directory by using the command:

dir /q

tim-hieu-velenh-dir-directory-in-cmd (7)

As you can see in the image above, the dir added a line for each file and directory is “DESKTOP-U7RQ5F1~~~~~”.

Part DESKTOP-U7RQ5F1 is the computer name, and “~~~~~” is the account name that created this File and Folder. (The name is a bit weird, sorry for me :D).

2.2. You can sort files or folders in the following order with the command:

dir /o:”Name-sort”

In which, the sort name includes types such as:

  • By Name (n): By name (Starting from the first letter az).

tim-hieu-velenh-dir-directory-in-cmd (8)

  • By Size: (S): By file size (Start from the smallest file size).

tim-hieu-velenh-dir-directory-in-cmd (9)

  • By Extension (e): According to the file extension (Starting from the first letter a-z).

tim-hieu-velenh-dir-directory-in-cmd (10)

  • By Date/time (d): Over time (Start from the oldest appearing file or folder -> newest).

tim-hieu-velenh-dir-directory-in-cmd (11)

  • Group Directories First (g): List all directories first, files later.

tim-hieu-velenh-dir-directory-in-cmd (12)

Note: You can add a comma (-) before the sort name to reverse the arrangement of the File or Folder. For example, if you want to sort files first, folders later, use the following command:

dir /o:-g

tim-hieu-velenh-dir-directory-in-cmd (13)

Dir also has the following commands:

  • dir /d or dir /w: View the list horizontally.

tim-hieu-velenh-dir-directory-in-cmd (14)

  • dir /c: Allows us to display commas after each row for file sizes (thousands, hundreds,…) and is enabled by default.
See more:  How to install Windows Terminal on Windows 10 standard!

tim-hieu-velenh-dir-directory-in-cmd (15)

  • dir /-c: Turn off displaying commas for file sizes.

tim-hieu-velenh-dir-directory-in-cmd (16)

  • dir /b: Show only file or folder names.

tim-hieu-velenh-dir-directory-in-cmd (17)

  • dir /p: Only used for batch files. After using the command, you will need to press any key to turn off the pop-up command.

tim-hieu-velenh-dir-directory-in-cmd (18)

#3. Epilogue

Okay, that’s it, I’ve finished guiding you almost all DIR commands on Windows operating system okay then.

Wish you success, if you have any problems and difficult to understand, just comment below this article, I will help you as soon as possible!

CTV: Hoang Tuan – techtipsnreview

Note: Was this article helpful to you? Don’t forget to rate the article, like and share it with your friends and family!

Source: Learn about the DIR . command [Directory] in CMD [Command Prompt]
– TechtipsnReview

Leave a Reply

Your email address will not be published. Required fields are marked *