If you have ever downloaded your WordPress wp-content/uploads/ folder to your Windows desktop for backup or migration, you have probably noticed a massive amount of storage bloat. A single high-resolution image upload often generates five, eight, or even a dozen smaller variations automatically.
Take an image named product-hero.png as an example. Once uploaded, WordPress instantly creates a sprawling list of thumbnails:
product-hero.png <-- Your original master image
product-hero-150x150.png <-- Auto-generated thumbnail
product-hero-300x200.png <-- Auto-generated medium size
product-hero-768x512.png <-- Auto-generated medium-large
product-hero-1024x683.png <-- Auto-generated large
product-hero-1536x1024.png <-- Auto-generated 2x retina size
When you have thousands of photos, an upload folder that should take up 2 GB can quickly balloon past 15 GB. If you want to keep only your original master photos and wipe out all auto-generated duplicates, doing it manually is out of the question.
Here is a quick, safe method to remove every resized variation across your entire folder structure in seconds using native Windows PowerShell—without downloading any sketchy third-party cleaner tools.
How the WordPress Naming Pattern Works
WordPress follows a strict, predictable naming rule when creating responsive sizes. It appends a hyphen followed by dimensions before the file extension:
filename-150x150.pngbanner-1920x1080.jpgavatar-64x64.webp
Because of this convention, we can target these files with a precise Regular Expression (Regex) pattern:
-\d+x\d+$
-\d+matches the hyphen and width digits.xmatches the literal dimension separator.\d+$matches the height digits right at the end of the base file name.
Your original files (like go.png, vacation-2026.jpg, or banner.png) will remain untouched because they do not end with this specific dimension signature.
Step 1: Open PowerShell in Your Image Folder
You don’t need to type out long folder paths. Windows lets you launch PowerShell right where you need it:
- Open your downloaded image folder (e.g.,
mypicsoruploads) in Windows File Explorer. - Click on the empty space inside the address bar at the top.
- Type
powershelland press Enter.
A PowerShell window will immediately pop up, already pointed directly at your folder.
Step 2: Run a Safe Dry-Run (Preview First)
Before deleting anything, always run a test pass to verify what files match the filter without touching anything on disk. Paste this command into PowerShell and press Enter:
Get-ChildItem -Path . -Recurse -File | Where-Object { $_.BaseName -match '-\d+x\d+$' } | Select-Object FullName
What this does: It scans every file and subfolder (-Recurse), checks if the name matches the dimension pattern, and prints the list on your screen. Verify that only files ending in dimensions like -150x100.png show up, and that your original files are not on the list.
Step 3: Delete All Resized Variations
Once you are happy with the preview list, execute the cleanup command:
Get-ChildItem -Path . -Recurse -File | Where-Object { $_.BaseName -match '-\d+x\d+$' } | Remove-Item -Force
PowerShell will cycle through your entire folder tree, purge every matched thumbnail variation, and leave you only with your clean master originals.
Safer Alternative: Move to Recycle Bin Instead of Permanent Delete
By default, PowerShell’s Remove-Item command permanently wipes files from the hard drive. If you want the security of being able to hit “Undo” from the Windows Recycle Bin, use this snippet instead:
Add-Type -AssemblyName Microsoft.VisualBasic
Get-ChildItem -Path . -Recurse -File | Where-Object { $_.BaseName -match '-\d+x\d+$' } | ForEach-Object {
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($_.FullName, 'OnlyErrorDialogs', 'SendToRecycleBin')
}
This safely redirects all deleted variations straight into your Windows Recycle Bin.
Quick Reference Cheat Sheet
| Action | PowerShell Command |
|---|---|
| Preview Targets | Get-ChildItem -Path . -Recurse -File | Where-Object { $_.BaseName -match '-\d+x\d+$' } | Select-Object FullName |
| Permanent Delete | Get-ChildItem -Path . -Recurse -File | Where-Object { $_.BaseName -match '-\d+x\d+$' } | Remove-Item -Force |
| Send to Recycle Bin | Add-Type -AssemblyName Microsoft.VisualBasic; Get-ChildItem -Path . -Recurse -File | Where-Object { $_.BaseName -match '-\d+x\d+$' } | ForEach-Object { [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile($_.FullName, 'OnlyErrorDialogs', 'SendToRecycleBin') } |
A Quick Word on Live WordPress Sites
This script is designed for local folders, offline archives, and staging backups. If you are cleaning an active production WordPress server, do not delete image files directly via FTP or file manager without using a plugin like Media Cleaner or the WP-CLI command wp media regenerate. Deleting active files off a live server leaves broken thumbnail links stored inside your database’s attachment metadata.

