{"id":540,"date":"2026-04-06T11:15:16","date_gmt":"2026-04-06T11:15:16","guid":{"rendered":"https:\/\/xuan.co.uk\/?p=540"},"modified":"2026-04-22T12:32:50","modified_gmt":"2026-04-22T12:32:50","slug":"list-all-folders-and-space-they-use","status":"publish","type":"post","link":"https:\/\/xuan.co.uk\/?p=540","title":{"rendered":"list all folders and space they use"},"content":{"rendered":"<p>I want to get the space used by every folder with the lowest permissions required<\/p>\n<p>Powershell<\/p>\n<p>The best, show folders like the tree command with at least 1GB of space used. You can use &#8220;&gt; c:\\folders.txt&#8221;\u00a0 to pipe it<\/p>\n<p>function f($p=&#8217;.&#8217;,$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=&#8217;-&#8216;*$i;Write-Host &#8220;$x&gt; [$g GB] $($_.Name)&#8221;;f $_.FullName ($i+4)}}}; f &#8220;C:\\Your\\Folder&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p>$p=Read-Host &#8220;Path&#8221;; $d=[int](Read-Host &#8220;Depth (Default 1)&#8221; -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 &#8220;`nSKIPPED FOLDERS (Access Denied):&#8221; -FC Red; $e.TargetObject | Select -Unique | % { Write-Host &#8220;[-] $_&#8221; -FC Gray } }<\/p>\n<p>&nbsp;<\/p>\n<p>Similar but all.<\/p>\n<p>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 &#8220;$mb\u00a0 === $($_.FullName)&#8221; }\u00a0 &gt; folders.txt<\/p>\n<p>&nbsp;<\/p>\n<p>MS Dos version<\/p>\n<p>for \/f &#8220;tokens=*&#8221; %G in (&#8216;dir \/ad \/b \/s&#8217;) do @for \/f &#8220;tokens=3&#8221; %S in (&#8216;dir &#8220;%G&#8221; ^| find \/i &#8220;file(s)&#8221;&#8216;) do @echo %S === %G &gt;&gt; folders.txt<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;&gt; c:\\folders.txt&#8221;\u00a0 to pipe it function f($p=&#8217;.&#8217;,$i=0){dir $p -Dir -ea 0|%{$s=(dir $_.FullName -Rec -File -ea 0|measure <a class=\"more-link\" href=\"https:\/\/xuan.co.uk\/?p=540\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-540","post","type-post","status-publish","format-standard","hentry","category-tech-tips"],"_links":{"self":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=540"}],"version-history":[{"count":5,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/540\/revisions"}],"predecessor-version":[{"id":549,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/540\/revisions\/549"}],"wp:attachment":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}