Skip to content

Repository files navigation

DownloadDeleter

Latest release License: MIT

A small Windows tool that automatically cleans up your Downloads folder. Anything older than the retention period (default 7 days) gets removed once an hour.

Why

Downloads folders fill up. Installers, screenshots, PDFs, ZIPs — you grab them, use them once, and forget about them. Cleaning up by hand is annoying and easy to put off.

A sliding retention window fixes this: anything that hasn't been touched in N days just leaves. Downloads turns into a self-cleaning staging area instead of an unsorted archive.

The retention period also forces you to decide what's actually worth keeping. If you want to hang on to something, you have to move it somewhere — Documents, a project folder, wherever you keep stuff that matters. You can't just leave it in Downloads and hope. Either you touch the file, you move it, or you accept that it's gone in N days.

How it works

The exe lives in your Windows Startup folder and launches on every logon. Once an hour, it sweeps Downloads.

Top-level files are checked one by one. If both the creation time and the last-write time are older than the retention period, the file goes to the Recycle Bin.

Top-level subdirectories are all-or-nothing. The sweep walks the whole tree under each one and only deletes the directory if every single file inside is past the threshold. A single recent file at any depth protects the entire subtree. That's deliberate: files that belong together usually stay together, and one recently-touched file is a strong hint that the bundle is still being used.

Recycling is atomic: a folder goes to the Recycle Bin as a whole or not at all, so it's never left half-deleted. If something inside is open in another program, the sweep skips it and tries again next hour instead of forcing it. The only things hard-deleted are items the Recycle Bin structurally can't accept — reserved DOS device names (nul, con, aux, prn, com0com9, lpt0lpt9, including extensions like nul.txt) and names with trailing dots or spaces — and even those are first renamed aside atomically, which Windows refuses if anything inside is open. So an in-use tree can never be gutted. Each hard-delete is logged.

If anything needs your attention, a Download Deleter Errors.txt shows up in your Downloads folder. It has two parts: a Currently in use list of things that couldn't be removed yet because they're open somewhere — this refreshes every sweep and the file disappears the moment everything clears — and a History of anything that had to be hard-deleted and why. It lives in Downloads so you'll actually see it.

Only one instance can run at a time. Try to launch a second copy and you'll get a message box telling you it's already running.

Install

  1. Download DownloadDeleter.exe from the latest release.
  2. Run it. A small dialog opens.
  3. Set how many days to keep files for (default is 7).
  4. Click Install.

That's it. The dialog copies itself into your Windows Startup folder, starts the background sweep, and goes away. From now on it runs silently on every login.

Change retention or uninstall

Run DownloadDeleter.exe again any time. The dialog shows what's currently installed — its version and retention period — and pre-fills the retention field with the current value. Change the number and click Update, or click Uninstall to remove it.

If the version you just downloaded is newer than the one in your Startup folder, the action button reads Update to vX.Y.Z so the upgrade path is obvious. Upgrading and changing retention are the same click.

How retention is stored

The exe in your Startup folder is renamed to encode the retention period (e.g. DownloadDeleter30.exe for 30 days, DownloadDeleter7.exe for the default). The installer does that for you. The same single binary is both the installer (when its filename has no suffix) and the background sweep (when it does).

Build from source

dotnet publish -c Release -r win-x64

Needs .NET 10. Produces a single self-contained NativeAOT exe around 2.2 MB at bin\Release\net10.0\win-x64\publish\DownloadDeleter.exe. Windows only; uses SHGetKnownFolderPath, the shell IFileOperation COM API (via source-generated COM), and MessageBoxW via P/Invoke.

Project layout

File Purpose
Program.cs Entry point: mode dispatch on filename suffix, mutex, hourly loop
Sweeper.cs One sweep pass + the error-log lifecycle (factored out for testing)
Recycler.cs Recycle Bin via IFileOperation, failure classification, safe staged hard-delete
Gui.cs Installer window, Install / Update / Uninstall actions
Native.cs P/Invokes for shell, user32, kernel32
Tests/ Behavioural test project — drives the real sweep against throwaway temp folders
DownloadDeleter.csproj AOT trim flags, version metadata
icon.ico Application icon (16/24/32/48/64/128/256 sizes)
LICENSE MIT license
CHANGELOG.md Version history

License

MIT — see LICENSE.

About

Tiny Windows utility that automatically deletes old files from your Downloads folder. .NET 10 NativeAOT, ~1.4 MB self-contained exe.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages