Categories We Write About

Scan directories for large files

To scan directories for large files, you can use built-in tools available on your operating system. Here are methods for Windows, macOS, and Linux:


Linux / macOS (Terminal)

1. Find files larger than 100MB in a directory:

bash
find /path/to/dir -type f -size +100M -exec ls -lh {} ; | awk '{ print $9 ": " $5 }'

2. List top 10 largest files recursively:

bash
du -ah /path/to/dir | sort -rh | head -n 10

3. Only files, excluding directories:

bash
find /path/to/dir -type f -exec du -h {} + | sort -rh | head -n 10

Windows (PowerShell)

1. List top 10 largest files in a folder:

powershell
Get-ChildItem -Path "C:PathToDir" -Recurse -File | Sort-Object Length -Descending | Select-Object FullName, @{Name="SizeMB";Expression={[math]::round($_.Length / 1MB, 2)}} -First 10

2. Find all files larger than 100MB:

powershell
Get-ChildItem -Path "C:PathToDir" -Recurse -File | Where-Object { $_.Length -gt 100MB } | Select-Object FullName, @{Name="SizeMB";Expression={[math]::round($_.Length / 1MB, 2)}}

Cross-platform Tools

1. ncdu (Linux/macOS)

Install and run:

bash
sudo apt install ncdu # Ubuntu/Debian brew install ncdu # macOS with Homebrew ncdu /path/to/dir

Interactive and efficient disk usage viewer.

2. WinDirStat (Windows)


Let me know your platform and directory target if you want a specific script.

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About