Great question! In the Windows Command Prompt, the dir command is used to list files and directories, and it accepts several switches (options) to modify its behavior. Here's what each of the switches you asked about does:
/a – Show files with specific attributes
This switch filters files based on their file attributes.
Example: dir /a will show all files, including hidden and system files.
You can also combine it with a letter to filter for specific attribute types:
/a:h – Hidden files
/a:s – System files
/a:r – Read-only files
/a:d – Directories
/a:-h – Files without the hidden attribute
/o – Order the output
Controls how the output is sorted.
Example: dir /o will sort the output.
Common sorting options:
/o:n – Sort by name (A–Z)
/o:e – Sort by extension
/o:g – Group directories first, then files
/o:s – Sort by file size
/o:d – Sort by date/time (oldest first)
/o:-d – Reverse sort by date/time (newest first)
You can combine multiple sort criteria, e.g., /o:ns.
/s – Search subdirectories
This tells dir to look in the current directory and all subdirectories.
Example: dir /s *.txt will list all .txt files in the current folder and any nested folders.
/b – Bare format
Displays only the file/directory names and paths.
Omits extra details like file size totals, headers, and summary information.
Useful when scripting or redirecting output to a file.