How to Automatically Delete Temp Files in Windows 7/8/10/11

Brithny updated on Sep 24, 2024 to Data Recovery Solution | How-to Articles

Do you need to delete some temporary files in Windows? Those stored in the temp folder are not needed and can be deleted. This is how to do it. Follow this post to delete all the temporary files and folders you have selected without difficulty.

Temp Files Are Taking Too Much Space! How to Auto-Delete Them

Windows always have temp files and other junk that's just taking up space on your hard drive. We've covered several ways to clean up the junk by using Disk Cleanup to using a third-party utility like CCleaner. Most of the methods in that article end up cleaning out the Temp folder, but you might want to keep that folder as clean as possible. 

This article shows you how to automatically delete temporary files no matter they are from APPs, recycle bin or download folder, just follow these details below and you will be able to delete temporary files automatically.

Method 1. Create a Batch File to Automatically Clean Temp Folder

No matter you are using Windows 7 or Windows 10, you are able to auto delete temp files by creating a batch file. A lot of space can end up being saved on your hard drive by clearing out the Temp file. And if you shut down your PC every night, you can safely delete the temp files from the previous day during boot.

1. Open Notepad and type in the following:

rd %temp% /s /q

md %temp%

2. Now, save the file exactly as the path below:

%appdata%\microsoft\windows\start menu\programs\startup\cleantemp.bat

That will create your batch file and save it inside the Startup folder.

After creating the batch file, you can reboot your PC and opened the Temp folder, you can see there are far fewer files than before.

Method 2. Automatically Delete Temp Files in Windows 10

With Windows 10 Fall Creators Update (version 1709), Microsoft introduced a new option in Storage sense to automatically delete files from the Downloads folder or delete temp files that are not using. The option, when turned on (turned off by default), automatically deletes unchanged files and temp files from the Downloads folder or Recycle Bin after 30 days.

Notice:
While this is a handy option, please remember that Windows 10 automatically deletes all files (not just programs or any file type) that have not seen any changes over the past 30 days. So, you might lose important files. If you often save important files in the Downloads folder or Recycle Bin (which is not a good practice), this feature is not for you.

Step 1. Open Settings app. Navigate to System > Storage.

Step 2. In the Storage sense section, turn on the Storage sense feature by moving the slider to on position.

Step 3. Click Change how we free up space link. Once again, make sure that you have turned on Storage sense feature as mentioned in the first step.

Step 4. Turn on Delete temporary files that my apps aren't using option.

Then your Windows 10 will be able to delete temp files or other files automatically. 

Extra Tips: Recover Important Temp Files

If your Windows 10/8/7 delete some of your important files accidentally, you still have a chance to get them back. You can just try a data recovery software from EaseUS. It allows you to restore up to 2GB files for free. You can directly download it here and recover automatically deleted files easily.

Step 1. Select a location and start scanning

Launch EaseUS Data Recovery Wizard, hover on the partition/drive where the deleted files were stored. Click "Search for Lost Data" to find lost files.

Step 2. Select the files you want to recover

When the scanning has finished, select the deleted files you want to recover. You can click on the filter to display only the file types you want. If you remember the file name, you can also search in the search box, which is the fastest way to find the target file.

Step 3. Preview and recover deleted files

Preview the recoverable files. Then, select files you want to restore and click "Recover" to store the files at a new storage locations instead of the disk where the data was previously lost. You can choose a cloud storage, such as OneDrive, Google Drive, etc., and click "Save" to save your recovered files.