A large number of temporary files are created on Windows, which are not always deleted automatically and over time take up more and more disk space. In this article, we will look at how to effectively delete temporary files in Windows 10.
Delete Temporary Files on Windows 10 Using Storage
In modern Windows 10 builds, you can quickly delete temporary files from the Settings menu. Press Win + I and go to System > Storage. In our example, Windows shows that there are about 2.4 GB of temporary files on the disk.
Click on the Temporary files icon. In the window that opens, the Cleanup Wizard will run and show how much space can be cleaned up due to temporary files. It is proposed to clean up temporary files for the following components:
- Windows Update Cleanup;
- Downloads;
- Windows upgrade log files;
- Recycle Bin;
- Thumbnails;
- Windows Defender Antivirus;
- Temporary Windows installation files;
- Delivery Optimization Files;
- Temporary Files;
- System error minidump files;
- Temporary Internet Files;
- DirectX Shader Cache.
Select the features you want to cleanup and click the Remove Files button.
Disk Cleanup Tool in Windows 10
In Windows 10, as in previous versions of Windows, there is a built-in Disk Cleanup manager. To start it press the key combination Win + R > type cleanmgr > hit Enter.
By default, Disk Cleanup tool offers to clear only temporary files of the current user. To delete temporary system files, click the Cleanup system files button (you will need to specify administrator credentials after showing UAC prompt).
Select the files you want to delete and click OK.
Clean up Temp Files with Scripts
You can also manually clean the following directories, which are used by most applications and Windows 10 itself:
- C:/Windows/Temp
- C:/Users/%UserName%/AppData/Local/Temp
- C:/Users/%UserName%/AppData/Local/Microsoft/Windows/Temporary Internet Files
You can create a simple batch script that removes all files older than 14 days from temporary directories. Create a text file cleanuptemp.bat with the following code:
SET Path1Del=C:/Windows/Temp SET Path2Del="C:/Users/%UserName%/AppDataLocal/Microsoft/Windows/Temporary Internet Files" forfiles.exe /p %temp% /s /m *.* /d -14 /c "cmd /c del /q /f @file" forfiles.exe /p %Path1Del% /s /m *.* /d -14 /c "cmd /c del /q /f @file" forfiles.exe /p %Path2Del% /s /m *.* /d -14 /c "cmd /c del /q /f @file"
Run the bat file with administrator privileges.
Hint. You can also use the following PowerShell script to automatically delete files older than 14 days from temporary folders:
$Path = "C:/Windows/Temp" $Days = "-14" $CurrentDate = Get-Date $OldDate = $CurrentDate.AddDays($Days) Get-ChildItem $Path -Recurse | Where-Object { $_.LastWriteTime -lt $OldDate } | Remove-Item -force
To automatically clean up temporary files once a week, you can create the following task in the Task Scheduler.
Schtasks.exe /Create /RL Highest /TN CleanUpTemp /SC Weekly /D SUN /ST 20:00 /TR "C:/PS/cleanuptemp.bat"
- Lens Kubernetes IDE – Opensource Lens Desktop - January 27, 2023
- Using Select-Object Cmdlet in PowerShell - January 26, 2023
- How to Turn Off Siri Suggestions on iPhone? - January 25, 2023