Over time, screenshots, temporary files, and other digital clutter can accumulate on your Windows system, slowing down performance and eating up valuable storage space. Manually cleaning up these files can be tedious and easy to forget, which is why automating the process is the smart way to keep your system tidy. Here's a step-by-step guide to automate the deletion of old screenshots and temporary files on Windows.
Use Windows Storage Sense
Windows 10 and 11 include a built-in feature called Storage Sense that can automatically delete unnecessary files, including temporary files and items in the Recycle Bin.
How to Enable and Configure Storage Sense:
- Open Settings → System → Storage.
- Toggle Storage Sense to On.
- Click Configure Storage Sense or run it now.
- Customize the following options:
Storage Sense runs automatically at regular intervals, keeping your system clean without manual effort.
Create a Scheduled Task for Old Screenshots
For screenshots or other files stored in specific folders, you can use Windows Task Scheduler along with a simple PowerShell script to automatically delete files older than a certain number of days.
Steps to Create the Script:
$Days = 30
Get-ChildItem $Path -Include *.https://www.amazon.com/s?k=PNG&tag=organizationtip101-20, *.jpg -Recurse | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$Days) } | Remove-https://www.amazon.com/s?k=item&tag=organizationtip101-20 -Force
$Path: Path to your screenshots folder.$Days: Files older than this number of days will be deleted.- File types can be adjusted as needed (e.g.,
*.jpg,*.png).
- Save the file as
DeleteOldScreenshots.ps1.
Steps to Schedule the Task:
-
Open Task Scheduler → Create Basic Task.
-
Name your task, e.g., "Delete Old Screenshots."
-
Choose a Trigger (daily, weekly, or monthly).
-
For Action , select Start a Program , and set Program/Script to:
-
In Add arguments , type:
-
Finish the setup. Your script will now run automatically according to your chosen schedule.
Use Disk Cleanup for Temporary Files
The classic Disk Cleanup tool in Windows can also be automated via a command line, making it possible to schedule regular cleanups for temporary files.
Steps:
- Save it as
DiskCleanup.bat. - Open Disk Cleanup , configure the cleanup settings, and select Set Files to Delete → Save Settings.
- Schedule the
.batfile in Task Scheduler, just like the PowerShell script above.
This method will remove temporary files, system cache, and other unneeded data automatically.
Use Third-Party Tools (Optional)
If you want a more user-friendly approach, several third-party utilities can automate file deletion without scripting:
- CCleaner : Offers scheduled cleaning for temporary files, browser cache, and screenshots.
- BleachBit : Lightweight and open-source, supports automated cleanups.
- Wise Disk Cleaner : Free tool that can automatically remove junk files on a schedule.
These tools provide extra flexibility but make sure to configure them carefully to avoid deleting important files.
Tips for Safe Automation
Automating file deletion is powerful, but it comes with risks if not set up carefully. Follow these best practices:
- Test scripts manually first before scheduling them to make sure they delete only the intended files.
- Back up important screenshots or temporary files that you may need later.
- Use filters by file type and folder to prevent accidental deletion of crucial documents.
- Monitor scheduled tasks occasionally to ensure they run as expected.
Automating the deletion of old screenshots and temporary files keeps your system efficient and clutter-free with minimal effort. With built-in tools like Storage Sense, PowerShell scripts, or third-party cleaners, you can ensure your Windows PC stays clean without lifting a finger.