PowerShell: List Directories

By Xah Lee. Date: . Last updated: .

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

PowerShell

Practical How-To

list files

list dirs

on dir

on file

Windows config

misc


PowerShell in Depth

Programing PowerShell

Value Types

String

Variable

Boolean

Conditional

Data Structure

Loop and Iteration

Input/Output

Function

Profile and Script

Script Examples