How to Automatically Delete Old Files on Windows 11

Over time, your Windows 11 PC accumulates tons of unnecessary files—temporary logs, old downloads, leftover update files, unused documents, and more. These files not only take up precious storage space but can also slow down your system if not cleaned regularly. Manually deleting old files is time-consuming, which is why many users prefer automatic cleanup tools built directly into Windows.

If you’re here reading this guide, you’re probably looking for a way to let Windows 11 automatically delete older files without needing to remember it yourself. The good news? Windows includes multiple built-in tools—like Storage Sense, Automatic User Folder Cleanup, and Temp File Cleanup—that can remove old files at regular intervals.

In this detailed, step-by-step guide, we’ll show you every method to automatically delete old files on Windows 11, whether you want to clean temp files, downloads, recycle bin content, or custom folders.

1. Use Storage Sense to Automatically Delete Old Files (Best Method)

Storage Sense is Windows 11’s built-in automatic cleaning utility. It removes temporary files, old downloads, recycle bin items, and other system debris.

Enable Storage Sense

  1. Open Settings on your PC.
  2. Go to System → Storage.
  3. Turn on: Storage Sense

Once enabled, Windows automatically begins managing unnecessary files.

2. Configure Storage Sense for Automatic Cleanups

To take full control, you can customize how Storage Sense cleans your storage.

  1. Under Storage Sense, click: Configure Storage Sense or run it now
  2. You’ll see multiple cleanup options:

Run Storage Sense Automatically

Under Run Storage Sense, choose one of the following frequencies:

  • Every day
  • Every week
  • Every month
  • During low free disk space

For automatic cleanup, set:

Every week or Every day

Delete Temporary Files Automatically

Turn on:

Delete temporary system and app files

Windows will remove cached data, temp logs, and old update files without affecting your apps.

Auto-delete Recycle Bin files

Under Delete files in my recycle bin if they have been there for over:

Choose:

  • 1 day
  • 14 days
  • 30 days
  • 60 days

This ensures deleted files don’t pile up forever.

Auto-delete old files in the Downloads folder

Under:

Delete files in my Downloads folder if they haven’t been opened for:

Choose a time limit:

  • 1 day
  • 14 days
  • 30 days
  • 60 days

Note: Be careful—important files might be deleted if untouched for long.

Run Cleanup Manually Anytime

At the bottom, click:

Run Storage Sense now

This forces a cleanup immediately.

3. Automatically Delete Old Temp Files via Disk Cleanup

Disk Cleanup still exists in Windows 11 and can be automated using Task Scheduler.

Steps to create an automated cleanup task:

  1. Press Windows + S and type: Task Scheduler
  2. Open it.
  3. Click Create Basic Task.
  4. Name it: Auto Temp File Cleanup

Set Trigger:

  1. Choose Daily or Weekly.
  2. Set a suitable time.

Set Action:

  1. Choose: Start a program
  2. In the Program field, type: cleanmgr.exe
  3. In Add arguments, enter: /sagerun:1

You must first configure preset “1” by running:

  1. Press Windows + R → type: cleanmgr /sageset:1
  2. Choose which temp files to delete.
  3. Save settings.

Windows will now automatically delete temp files on the schedule you set.

4. Automatically Delete Files in Specific Folders Using PowerShell Script + Task Scheduler

If you want Windows to automatically delete files older than a certain number of days from any custom folder, you can use a PowerShell script.

Create a PowerShell Cleanup Script

  1. Open Notepad.
  2. Paste the script below:
$Path = "C:\YourFolder"
$Days = 30
Get-ChildItem -Path $Path -Recurse | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-$Days))} | Remove-Item -Force
  1. Replace:
    • C:\YourFolder → folder to clean
    • 30 → number of days
  2. Save as:
DeleteOldFiles.ps1

Schedule the Script to Run Automatically

  1. Open Task Scheduler.
  2. Click Create Task.
  3. Under “Triggers,” set how often you want the script to run.
  4. Under “Actions,” choose: Start a Program
  5. For Program/script, enter: powershell.exe
  6. For “Add arguments,” insert:
-ExecutionPolicy Bypass -File "C:\Path\DeleteOldFiles.ps1"

Now Windows cleans that folder automatically based on your schedule.

5. Automatically Delete Old Cloud Files (OneDrive + Windows 11)

OneDrive includes automatic cleanup for files set to “online-only.”

  1. Open OneDrive Settings.
  2. Go to Sync and backup → Advanced settings.
  3. Enable: Files On-Demand

This removes local copies of unused cloud files while keeping them online.

6. Use Third-Party Cleanup Tools (Optional)

If you want more control or automation features, tools like:

  • CCleaner
  • BleachBit
  • Wise Disk Cleaner

Allow you to schedule deletion of old browser files, logs, and junk automatically. But for most users, Windows 11’s built-in options are more than enough.

Wrapping Up

And that wraps up our in-depth guide on how to automatically delete old files on Windows 11. Whether you use Storage Sense, Task Scheduler, PowerShell scripts, or cloud cleanup tools, Windows gives you plenty of powerful ways to keep your system clean without manual effort.

Posted by Arpita

With a background in Computer Science, she is passionate about sharing practical programming tips and tech know-how. From writing clean code to solving everyday tech problems, she breaks down complex topics into approachable guides that help others learn and grow.