When IT sends the email saying the department share is almost full and everyone should clean up their folders, the first question is which folders are actually big. File Explorer won't tell you. It shows a size for every file but leaves the Size column blank for folders, and a tool like TreeSize or WinDirStat usually can't be installed on a locked-down work PC.
So I wrote a PowerShell script that adds up every folder's total size, file count and newest file date, writes the result to a CSV file and opens it in Excel. You paste it in and it runs, with no install and no admin rights. On a folder with 60,000 files it took about 10 seconds and produced a 35-row list.

Why File Explorer can't show folder sizes, and what the other options miss
Windows doesn't keep a running total for folders, so the Details view in File Explorer leaves the Size column empty for every folder. (The screenshots in this post come from a Japanese copy of Windows, so the menus are in Japanese. The folder names are the ones the script reads.)

The folder dates don't help either. A folder's modified date changes only when something is added or removed directly inside it. Editing a file two levels down leaves it alone. In my test share, a folder whose newest file was from 2020 still showed the day I created it.
To see a total, you right-click a folder and open Properties. The number is accurate, but it covers one folder at a time. Comparing ten department folders means opening Properties ten times and writing the numbers down.

| Method | What it shows | What it misses |
|---|---|---|
| File Explorer Details view | File sizes | No folder sizes at all |
| Folder Properties | Total size and file count of one folder | One folder at a time, nothing to sort or compare |
dir /s in Command Prompt |
File count and bytes per folder | Counts only the files directly inside each folder, not its subfolders. Plain text that's awkward in Excel |
| TreeSize, WinDirStat and similar apps | Folder sizes as a chart or list | Need to be installed, which work PCs often block |
| My file list script | Size and date of every single file | One row per file. A pivot table can total folders, but only one level down |
| The script in this post | Total size, share of the whole, file count and newest file date per folder | No per-file details |
The file list approach also runs into Excel's limit. For the 60,000-file folder it would produce 60,313 rows, and a worksheet tops out at 1,048,576 rows, so a whole department share can be too big to open. The folder report for that same folder was 35 rows. The quickest order is to find the heavy folders with this script first, then list the files inside only those folders.
The script: folder sizes to CSV
Open PowerShell (Windows PowerShell 5.1 or PowerShell 7), change the first three settings and paste the whole thing in. You don't need to run it as administrator. When it finishes, the CSV opens in Excel.
# ===== Change these =====
$folder = "\\fileserver\shared" # Folder to check (a network share or a local drive)
$depth = 2 # How many levels of subfolders get their own row (1 = top-level folders only)
$csv = Join-Path ([Environment]::GetFolderPath("Desktop")) "folder-sizes.csv" # Output file (on the desktop in this example)
# ===========================
$opt = if ($PSVersionTable.PSVersion.Major -ge 6) { @{ Encoding = "utf8BOM" } } else { @{ Encoding = "UTF8"; NoTypeInformation = $true } }
$root = (Resolve-Path -LiteralPath $folder).ProviderPath.TrimEnd("\")
$timer = [Diagnostics.Stopwatch]::StartNew()
$sum = @{}
function New-Total { @{ Bytes = [long]0; Files = 0; Write = [datetime]::MinValue; Access = [datetime]::MinValue } }
$special = "(Total)", "(Files in top folder)"
$sum["(Total)"] = New-Total
# List the folders first so that empty folders also get a row
Get-ChildItem -LiteralPath $root -Directory -Recurse -Depth ($depth - 1) -Force -ErrorAction SilentlyContinue |
ForEach-Object { $sum[$_.FullName.Remove(0, $root.Length + 1)] = New-Total }
# Add each file to every folder above it, up to $depth levels
Get-ChildItem -LiteralPath $root -File -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable errs |
ForEach-Object {
$f = $_
$parts = $f.DirectoryName.Remove(0, $root.Length).Split("\", [StringSplitOptions]::RemoveEmptyEntries)
$keys = @("(Total)")
if ($parts.Count -eq 0) { $keys += "(Files in top folder)" }
for ($i = 1; $i -le [math]::Min($depth, $parts.Count); $i++) { $keys += ($parts[0..($i - 1)] -join "\") }
foreach ($k in $keys) {
$t = $sum[$k]
if (-not $t) { $t = New-Total; $sum[$k] = $t }
$t.Bytes += $f.Length
$t.Files++
if ($f.LastWriteTime -gt $t.Write) { $t.Write = $f.LastWriteTime }
if ($f.LastAccessTime -gt $t.Access) { $t.Access = $f.LastAccessTime }
}
}
$all = [math]::Max($sum["(Total)"].Bytes, 1)
$rows = foreach ($k in $sum.Keys) {
$t = $sum[$k]
[PSCustomObject]@{
Folder = $k
Level = if ($k -in $special) { 0 } else { $k.Split("\").Count }
SizeMB = [math]::Round($t.Bytes / 1MB, 1)
Percent = "{0:0.0}%" -f ($t.Bytes * 100 / $all)
Files = $t.Files
LastModified = if ($t.Files) { Get-Date $t.Write -Format "yyyy-MM-dd" } else { "" }
LastAccessed = if ($t.Files) { Get-Date $t.Access -Format "yyyy-MM-dd" } else { "" }
FullPath = if ($k -in $special) { $root } else { Join-Path $root $k }
}
}
$rows | Sort-Object { if ($_.Folder -eq $special[0]) { "0" } elseif ($_.Level -eq 0) { "1" } else { "2" + $_.Folder } } | Export-Csv -LiteralPath $csv @opt
"Wrote {0} rows ({1:N0} files, {2:N1} s): {3}" -f @($rows).Count, $sum["(Total)"].Files, $timer.Elapsed.TotalSeconds, $csv
if ($errs) { "Could not read {0} location(s), such as folders you have no access to. Their contents are not in the totals." -f $errs.Count }
$rows | Where-Object Level -eq 1 | Sort-Object SizeMB -Descending | Select-Object -First 5 Folder, SizeMB, Percent, LastModified | Format-Table -AutoSize
Invoke-Item -LiteralPath $csv
Feel free to use and modify the script.
What to change
| Line | What it does | Example |
|---|---|---|
$folder (line 2) |
The folder to check. A network share (\\server\share) or a local drive both work | "\\fs01\Sales" |
$depth (line 3) |
How many levels of subfolders get their own row. 1 lists only the top-level folders, and 2 also lists folders like 02_Sales\2025_Quotes. Totals always include everything below | 1, 2 or 3 |
$csv (line 4) |
Where to save the CSV. By default it goes to your desktop as folder-sizes.csv | "D:\work\sizes.csv" |
What the output looks like
I built a test share laid out like a typical department share (about 1.7 GB, 1,243 files) and ran the script against it. PowerShell prints the five biggest top-level folders as well.
Wrote 21 rows (1,243 files, 0.3 s): D:\...\folder-sizes.csv Folder SizeMB Percent LastModified ------ ------ ------- ------------ 04_Marketing 758.3 44.9% 2023-06-12 03_Production 310.9 18.4% 2026-11-26 Old_System_Migration 269.8 16.0% 2020-11-10 02_Sales 175.5 10.4% 2026-11-23 99_Personal 173.9 10.3% 2026-11-25
In Excel, the rows are in folder order with the total on top.

| Column | What it means |
|---|---|
| Folder | Path relative to the folder you scanned. (Total) is everything, and (Files in top folder) covers files sitting directly in it |
| Level | 1 for top-level folders, 2 for the folders inside them. Filter on 1 to compare departments |
| SizeMB, Percent | Total size including every subfolder, and its share of the whole |
| Files | Number of files inside, subfolders included. Empty folders show 0 |
| LastModified | The newest modified date of any file inside. An old date means nobody has touched the folder in a while |
| LastAccessed | The newest last access date of any file inside. Treat it as a rough hint (see below) |
| FullPath | The folder's location. Paste it into File Explorer to open it |
Filter Level to 1 and sort SizeMB from largest to smallest, and you get the screenshot at the top. In the test share, 04_Marketing holds about 45% of the space, and its newest file is from June 2023. It's photos and videos from an old event. Old_System_Migration is a single file using 16% of the share, untouched since 2020. Those are the folders to bring up first when the cleanup discussion starts.
To see the files inside a heavy folder, point the file list script at it. To clear out old material, my tool that moves old files into a ZIP does that part.
Don't trust the last access date too much
The LastAccessed column comes from each file's last access time. Knowing when someone last opened a file would make cleanup decisions easy, but this date is often wrong or missing.
First, Windows may not record it at all. Updating the access time means an extra disk write every time a file is read, so the feature can be switched off. This command shows your own PC's setting.
fsutil behavior query disablelastaccess
On my Windows 11 PC it printed the line below. ENABLED means access times are recorded, and DISABLED means they aren't.
DisableLastAccess = 2 (System Managed, Last Access Time Updates ENABLED)
For a network share, the file server's setting is what counts, and you usually can't check it. You can test it instead. Look at the access time of a file nobody has opened lately, open and close the file, then look again. If the time moved, the server records it.
(Get-Item -LiteralPath "\\fileserver\shared\01_Admin\policy.docx").LastAccessTime
Second, a recorded access isn't necessarily a person opening the file. NTFS can delay the update by up to an hour, and antivirus scans, backups and preview panes all read files too. In my own test, reading one file to check the setting was enough to change its folder's LastAccessed to that day. Base cleanup decisions on LastModified and use the access date only as a hint.
Things that tripped me up
Without -Force, the totals don't match Properties
Get-ChildItem skips hidden files unless you add -Force. When I took it out, the total dropped to 1,544.1 MB, about 150 MB less than Properties showed. Almost all of the gap was one hidden Outlook data file (.pst) in a personal folder, and 99_Personal went from 173.9 MB to 29.2 MB. That's the biggest file in the share going missing from a size report, so the script uses -Force.
Checking the access date changed it
I scanned the same share with PowerShell 5.1 and 7. Sizes, file counts and LastModified matched exactly, but three LastAccessed values didn't. Between the two runs, my test had read one file to check the access setting. Reading a file's contents updates its access time, and antivirus or backup software does the same. The script itself only reads file information, not contents, so running it doesn't change access times.
Junctions are not followed
I checked whether a junction (a folder link pointing somewhere else) would get counted twice. With a 50 MB folder and a junction pointing to it side by side, the junction's row showed 0 MB and the total stayed at 50 MB. In both 5.1 and 7, Get-ChildItem -Recurse doesn't walk into junctions. The flip side is that if a junction points to another drive, that data isn't in the total.
How long it takes
A local folder with 60,313 files, reported two levels deep (35 rows), took 10 to 12 seconds in PowerShell 5.1 over two runs and 5.6 seconds in PowerShell 7. A network share is slower because every file's details travel over the network. On a large share, run it with $depth set to 1 to get the big picture, then point $folder at the heavy folders to dig deeper.
If some folders deny you access, the script keeps going and reports how many places it couldn't read at the end. I tested this with a folder I denied myself access to. Those contents aren't in the totals, so ask the folder's owner to check them.
If it's your own C drive that's full, system folders are involved, and my post on finding hidden space on the C drive covers checking it with admin rights.
Summary
- File Explorer doesn't show folder sizes, and Properties shows only one folder at a time
- One pasted script turns every folder's total size, share, file count and newest file date into an Excel list
- Use
-Forceso hidden files are counted, and treat the last access date as a hint, not a fact

Comments