Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Auto Delete Old Files in Windows: Step-by-Step

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Over time, your Windows PC fills up with temporary files, old downloads, and outdated backups. Setting Windows to automatically delete old files helps free up disk space and keeps your system tidy without manual cleanup. This guide shows you how to use built-in tools like Storage Sense, Task Scheduler, and File Explorer's cleanup options. No third-party software is needed.

What You'll Need

  • A Windows 10 or Windows 11 PC with administrative rights (for some steps).
  • An internet connection if you want to use cloud-based cleanup (optional).
  • Basic familiarity with navigating Settings and Control Panel.

Step-by-Step

Method 1: Use Storage Sense (Windows 10 & 11)

  1. Open Settings (press Win + I).
  2. Click System (Windows 11) or System > Storage (Windows 10).
  3. In Windows 11, click Storage in the left sidebar. In Windows 10, click Storage in the left menu.
  4. Find Storage Sense (Windows 10) or Storage management (Windows 11). Toggle it On.
  5. Click the Storage Sense link (Windows 10) or Advanced storage settings > Storage Sense (Windows 11) to configure it.
  6. Under Automatic User Content cleanup, set Run Storage Sense to Every day, Every week, or Every month.
  7. Set Delete temporary files that my apps aren't using to Never or a time period (e.g., 1 day).
  8. Set Delete files in my Recycle Bin if they have been there for over to a period (e.g., 30 days).
  9. Set Delete files in my Downloads folder if they have been there for over to a period (e.g., 30 days). Note: This affects all files in Downloads, so be careful.
  10. Click Clean now (Windows 10) or Run Storage Sense now (Windows 11) to test immediately.

Method 2: Use Task Scheduler to Run Disk Cleanup

  1. Press Win + R, type taskschd.msc, and press Enter.
  2. In the right pane, click Create Basic Task.
  3. Name the task (e.g., "Auto Cleanup") and click Next.
  4. Choose a trigger (e.g., Weekly) and click Next.
  5. Set the start date and time, select days, then click Next.
  6. Choose Start a program and click Next.
  7. In the Program/script field, type: cleanmgr.exe
  8. In the Add arguments field, type: /sagerun:1 (this runs the saved cleanup profile).
  9. Click Next, review, and click Finish.
  10. Before the task runs, you need to configure the cleanup profile. Open Command Prompt as administrator and run: cleanmgr /sageset:1
  11. In the dialog that appears, check the file types you want to delete (e.g., Temporary files, Recycle Bin, Thumbnails). Click OK.
  12. Now the scheduled task will run Disk Cleanup with those settings automatically.

Method 3: Use File Explorer's "Delete Files Older Than" (via PowerShell script)

  1. Open Notepad.
  2. Paste the following PowerShell script (adjust the path and age as needed):
  3. Get-ChildItem -Path "C:\Users\YourName\Downloads" -Recurse -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-30) } | Remove-Item -Force
  4. Replace C:\Users\YourName\Downloads with the folder you want to clean, and change -30 to the number of days.
  5. Save the file as Cleanup.ps1 (make sure the Save as type is "All Files").
  6. Open Task Scheduler as in Method 2, create a new task, and set the action to Start a program.
  7. In Program/script, type: powershell.exe
  8. In Add arguments, type: -ExecutionPolicy Bypass -File "C:\path\to\Cleanup.ps1"
  9. Set the trigger as desired (daily/weekly).

Common Mistakes

  • Deleting important files: Storage Sense's Downloads cleanup can remove files you still need. Always set a longer period or exclude the Downloads folder if you're unsure.
  • Using the wrong path in PowerShell: If you mistype the folder path, the script may fail or delete from the wrong location.
  • Not testing the scheduled task: After creating a task, run it manually once to ensure it works.
  • Forgetting to configure sageset: If you run cleanmgr /sagerun:1 without first running /sageset:1, nothing will be cleaned.

Tips

  • Start with a conservative age (e.g., 60 days) and adjust based on your needs.
  • Use Storage Sense for simplicity; it's the most user-friendly method.
  • For the PowerShell method, test the script on a test folder first.
  • Consider moving important downloads to a separate folder outside the one you auto-clean.
  • Set the scheduled task to run when the PC is idle (e.g., during lunch break) to avoid performance hits.

Troubleshooting

  • Storage Sense doesn't run automatically: Check that the toggle is on and that the PC is not in battery saver mode (which may delay it). Also, try restarting the PC.
  • Task Scheduler task fails: Right-click the task and select Run to see the error. Common issues: incorrect path, missing permissions. Ensure the task runs with highest privileges.
  • cleanmgr doesn't delete anything: Make sure you ran cleanmgr /sageset:1 as administrator and checked the boxes. Also, some files may be in use by the system.
  • PowerShell script says "access denied": Run the task with admin rights, or use a folder you have full control over.
  • Files reappear: Some apps (like browsers) recreate temp files. That's normal.

Frequently Asked Questions

Will Storage Sense delete my personal files?

Only if you enable the Downloads folder cleanup. It will not touch documents, pictures, or other personal folders unless you specifically configure it.

Can I set different ages for different folders?

Storage Sense applies one age for all Downloads and one for Recycle Bin. For per-folder control, use the PowerShell method or separate scheduled tasks.

Does this work on Windows 7?

No, Storage Sense is only available on Windows 10 and 11. On Windows 7, you can use Task Scheduler with cleanmgr, but the interface differs.

Will auto-deleting old files slow down my PC?

No, it usually speeds it up by freeing disk space. The scheduled task may run in the background, but it's lightweight.

Can I undo a deletion?

If files are deleted from the Recycle Bin, they are gone permanently. For files deleted by the PowerShell script, they are also permanently removed. Always use the Recycle Bin option if you want a safety net.

How often should I run cleanup?

Weekly is good for active users. Monthly is fine for light usage. Daily may be overkill and could delete files you still need.