list all folders and space they use

I want to get the space used by every folder with the lowest permissions required

Powershell

The best, show folders like the tree command with at least 1GB of space used. You can use “> c:\folders.txt”  to pipe it

function f($p=’.’,$i=0){dir $p -Dir -ea 0|%{$s=(dir $_.FullName -Rec -File -ea 0|measure Length -s).Sum;$g=[math]::Round($s/1GB,2);if($g -ge 1){$x=’-‘*$i;Write-Host “$x> [$g GB] $($_.Name)”;f $_.FullName ($i+4)}}}; f “C:\Your\Folder”

 

$p=Read-Host “Path”; $d=[int](Read-Host “Depth (Default 1)” -Default 1); Get-ChildItem $p -Dir -Recurse -Depth $d -EA 0 -EV e | % { $s = (Get-ChildItem $_.FullName -File -Recurse -EA 0 | Measure-Object Length -Sum).Sum / 1GB; if($s -ge 1.5){ [PSCustomObject]@{ GB = [Math]::Ceiling($s); Path = $_.FullName } } } | Sort GB -Desc | FT -AutoSize; if($e){ Write-Host “`nSKIPPED FOLDERS (Access Denied):” -FC Red; $e.TargetObject | Select -Unique | % { Write-Host “[-] $_” -FC Gray } }

 

Similar but all.

Get-ChildItem -Directory -Recurse | ForEach-Object { $size = (Get-ChildItem $_.FullName -File -Recurse -ErrorAction SilentlyContinue | Measure-Object Length -Sum).Sum; $mb = [math]::Round($size / 1MB, 2); Write-Host “$mb  === $($_.FullName)” }  > folders.txt

 

MS Dos version

for /f “tokens=*” %G in (‘dir /ad /b /s’) do @for /f “tokens=3” %S in (‘dir “%G” ^| find /i “file(s)”‘) do @echo %S === %G >> folders.txt

 

Posted on April 6, 2026, 11:15 am By
Categories: tech tips