PowerShell: List Directories

By Xah Lee. Date: . Last updated: .

💡 TIP: Command names and parameter names are case-insensitive.

List Directory Only

List directories only (no file) of current directory:

dir -Directory -Recurse

Show just path (relative to current dir):

dir -Directory -Recurse -name

Show full path path:

dir -Directory -Recurse | ForEach-Object { $_.fullname }

Show Directory as Tree

This is a command at C:/Windows/system32/tree.com

# show dir as tree, dir only
tree
# show dir as tree, include files
tree /f

sample output:

├───assets
├───dist
│   ├───chromium
│   └───firefox
├───doc
│   ├───description
│   ├───img
│   └───screenshots

PowerShell, Working with Directory