PowerShell: dir size 📜
Directory Size
put this in your PowerShell Profile
function xah-dir-size { # .DESCRIPTION # Show dir size (counts all subdirs) # First arg is path of a dir. Default to current dir. # .NOTES # Version: 2022-06-07 2022-06-28 2022-08-28 # .LINK # http://xahlee.info/powershell/powershell_dir_size.html Param( [string] $path ) $total = ((Get-ChildItem $path -File -Recurse | Measure-Object -Property Length -Sum).sum); "{0:n0} bytes" -f $total; }
Show Sizes of Subdirs
function xah-subdir-sizes { # .DESCRIPTION # Show every subdir size. # First arg is path of a dir. Default to current dir. # .NOTES # Version: 2022-06-07 2024-03-08 # .LINK # http://xahlee.info/powershell/powershell_dir_size.html Param( [string] $path ) Get-ChildItem $path -Directory | foreach { $total = ((Get-ChildItem $_ -File -Recurse | Measure-Object -Property Length -Sum).sum ); Write-Host $_.name " " -NoNewline; "{0:n0} bytes" -f $total; } }
PowerShell. List Dirs and Files
List Dirs
- PowerShell: navigate directory
- PowerShell: show current dir path
- PowerShell: list directories
- PowerShell: show directory as tree
- PowerShell: list empty dir 📜
- PowerShell: dir size 📜
List Files
- PowerShell: list files
- PowerShell: show fullpath, no truncate lines
- PowerShell: list empty files 📜
- PowerShell: count files
- PowerShell: list files by wildcard name pattern
- PowerShell: filter file name by regular expression
- PowerShell: sort files by size
- PowerShell: list large files 📜
- PowerShell: sort files by date
- PowerShell: search text in files (grep)