Does the Temp folder in Windows empty automatically?

No. Even the recycle garbage can is not automatically emptied unless it exceeds a quota set in the settings.

In fact, operating systems are not set by default to permanently delete data, this is also true for other OS than Windows.

The Temp directory of the root volume is usually at the user’s discretion, also used by some applications, but many temporary files are created in other places (and sometimes properly deleted by the applications that create them).

You can actually create a scheduled task, or autostart, based on cmd commands or PowerShell to handle this. That’s one idea.

But there is a specific setting that allows you to manage the quotas of several basic folders.

Open “settings” from the “search” field in the taskbar. Choose “storage”.

You will then see options to set different settings for automatic cleaning.

The default option does not normally allow automatic cleaning of supported base folders (storage assistant). The Temp folder is not in the list of basic folders, but it can be managed from this “storage” window, in the “other” sub-list

Automatic cleaning can be set to auto. This is a possibility to optimize the used storage. But be careful: some users sometimes lose files, badly placed, with the automatic cleaning. And some applications hope to find information placed there, with a more or less long life. A badly “calibrated” cleanup can sometimes cause restart problems, if the cleanup is too frequent (however, the temporary files, for example, of Office office tools, are stored in the user document directories and not in the “system” temporary files).

If you need automatic cleaning by quotas applied on users, for all the consumption of a user, it is possible to put rules allowing to do it. But these rules cannot be applied by folder in Windows Workstation (unlike Windows Server which allows you to cross-reference user and folder quotas).

You could, therefore, create a batch procedure, a .bat file that allows you to find the list of files you want to clean in a folder, in a recursive way (with subfolders), or not recursive.

For this you can use system commands such as DEL, or RMDIR (with the /S option to delete a folder and all its contents).

There is also, for a finer management of the problem either the FOR command, or the command, more precise perhaps FORFILES.

> forfiles /P C:\Temp /d -120

allows you, as an example, to retrieve the list of files created at least 120 days ago, in the folder C:\Temp

> forfiles /P C:\Temp /d -8 /C “cmd /c del @file”

allows you to physically delete files in the C:\Temp directory that are at least 8 days old.

From such a command, you have the choice to launch it manually, by double-clicking in the file explorer on its icon, but you can also make it a scheduled task, if you are sure of your goal.

To make it a scheduled task, you need to open the task scheduler, from Cortana for example, and create a new task, for which you will define the launch schedule parameters, and which will call the .bat file created as mentioned above.

Translated with www.DeepL.com/Translator (free version)