Hi Rich Wilk,
I’m following up to check whether the issue has been resolved. Feel free to reply if you need further information. If the information provided was helpful, please click "Accept Answer" to help others in the community. Thank you!
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Make the list of the DIR command's options, switches and other useful DIR or ls options
Hi Rich Wilk,
I’m following up to check whether the issue has been resolved. Feel free to reply if you need further information. If the information provided was helpful, please click "Accept Answer" to help others in the community. Thank you!
Hi Rich Wilk,
Below is a complete list of useful switches, parameters, and equivalents for both CMD and PowerShell.
1. Classic CMD dir Options
These are the traditional switches available in Command Prompt:
Switch Description
2. PowerShell DIR (Alias for Get-ChildItem)
PowerShell expands functionality with parameters:
Parameter Description
3. Useful Equivalents
dir /s /b > PowerShell:
Get-ChildItem -Recurse -Name
dir /a:h (hidden files) > PowerShell:
Get-ChildItem -Force
dir /o:n (sort by name) > PowerShell:
Get-ChildItem | Sort-Object Name
I hope the response provided some helpful insight. If it clarified the issue for you, please consider marking it as Accept Answer so others with the same issue can find the solution.
Jason.
For classic cmd.exe the dir command options are:
[<drive>:][<path>] – Drive and directory to list.[<filename>] – File or file pattern to list (supports wildcards * and ?).Switches:
/p – Pause after each screen of output./q – Show file ownership information./w – Wide format (multiple names per line)./d – Wide format, sorted by column./a[[:]attributes] – Show only items with specific attributes. Attributes:
d – Directoriesh – Hidden filess – System filesl – Reparse pointsr – Read-only filesa – Ready for archivingi – Not content indexed files- prefix means “not”, e.g. /a:-d = files only, no directories./o[[:]sortorder] – Sort order. Values:
n – Name (alphabetical)e – Extension (alphabetical)g – Group directories firsts – Size, smallest firstd – Date/time, oldest first- prefix reverses order, e.g. /o:-n./t[[:]timefield] – Which timestamp to display/sort by:
c – Creation timea – Last accessedw – Last written/s – Recurse into all subdirectories./b – Bare format (names only, no header/summary). Overrides /w./l – Use lowercase, unsorted./n – Long list format with names on the far right./x – Show 8.3 short names in addition to long names./c – Show thousand separators in sizes (default). Use /-c to hide./4 – Four‑digit years./r – Show alternate data streams./? – Help for dir.Useful dir usage patterns (cmd):
dir.txt files on C: recursively, wide, sorted, with paging:
dir c:\*.txt /w /o /s /pdir /a:-d /bdir > prndir > \records\dir.docPowerShell dir / ls alias:
In PowerShell, dir and ls are aliases for Get-ChildItem.
Key Get-ChildItem options relevant to dir/ls behavior:
-Path – Target path (default is current location).-Recurse – Recurse into child containers.-Depth <n> – Limit recursion depth.-Directory (alias -ad) – Return directories only.Notes:
dir, gcilsGet-ChildItem -Recurse with -Path, the last path component is treated specially (can trigger recursive search for that component). For predictable recursion:
-LiteralPath for the base directory.-Filter or -Include for patterns.Examples (PowerShell):
dir or ls or Get-ChildItem.txt files under C:\Data:
Get-ChildItem -LiteralPath 'C:\Data' -Recurse -Filter '*.txt'Get-ChildItem -DirectoryReferences: