Forum Discussion
How to quickly find and delete large files on windows 11
Using PowerShell is an excellent way to find and delete large files on Windows 11 efficiently. You can leverage PowerShell's powerful cmdlets to search for files exceeding a certain size and then delete them if needed.
Here's a "PowerShell Magic" script to find and delete large files on Windows 11:
Find Large Files with PowerShell
This script searches a specified directory (e.g., your C: drive) for files larger than a specified size (e.g., 100MB):
# Define the directory to scan
$directory = "C:\"# Define the minimum file size (in bytes), e.g., 100MB = 100 * 1024 * 1024
$minSizeBytes = 100MB# Find files larger than the specified size
Get-ChildItem -Path $directory -Recurse -File | Where-Object { $_.Length -gt $minSizeBytes } | Select-Object FullName, Length
Delete Large Files
If you are sure you want to delete these files, add a removal command:
# WARNING: This will permanently delete files!
Get-ChildItem -Path $directory -Recurse -File | Where-Object { $_.Length -gt $minSizeBytes } | ForEach-Object {
try {
Remove-Item $_.FullName -Force
Write-Output "Deleted: $($_.FullName)"
} catch {
Write-Output "Failed to delete: $($_.FullName) - $_"
}
}
Tips:
Always review the list first before deleting.