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.
- White: Number of files and subfolders in Folder. Also list the available and free space of the hard drive containing this folder.
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
Read more articles: How to use CMD (Command Prompt) [đầy đủ & dễ hiểu]
Method 2: Enter command dir -path-of-directory. Specifically here is the command dir D:Server
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.
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
=> As you have seen, CMD only displays directories and ignores all files in the directory.
Note: Attributes can be combined. For example, if you want to filter only hidden folders, use the following command:
get out:dh (d: show folder, H: show hidden files and folders).
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:
As you can see in the image above, the dir added a line for each file and directory is
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:
In which, the sort name includes types such as:
- By Name (n): By name (Starting from the first letter az).
- By Size: (S): By file size (Start from the smallest file size).
- By Extension (e): According to the file extension (Starting from the first letter a-z).
- By Date/time (d): Over time (Start from the oldest appearing file or folder -> newest).
- Group Directories First (g): List all directories first, files later.
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 also has the following commands:
- dir /d or dir /w: View the list horizontally.
- dir /c: Allows us to display commas after each row for file sizes (thousands, hundreds,…) and is enabled by default.
- dir /-c: Turn off displaying commas for file sizes.
- dir /b: Show only file or folder names.
- 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.
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]