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
- 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 Number of Files
- PowerShell: List Files by Wildcard Name Pattern
- PowerShell: Filter File Name by Regular Expression
- PowerShell: List File by Size
- PowerShell: Sort Files by Size 📜
- PowerShell: List Files by Date Time
- PowerShell: Search Text in Files (grep)