Our computer collects a lot of temporary files in order to speed up certain processes and save time expended in searching them. But these temporary files take considerable amount of space of our disk which we might not want to happen.
Mostly, these files are stored in the Temp folder inside AppData directory, which we delete by opening the Run window and typing %temp% over there.
We need to do this periodically to prevent junking up of data and many times we face problems when some of the files over there are being locked by some active processes.
We can reduce the pain of opening and deleting the temporary files manually by writing a batch script in Windows, so that, everything is done automatically by a single mouse click. So, we just need to take the pain of running a script each time we want to clear the temporary files.
We can also hand over even this pain to Windows, so that it automatically runs the script at a certain time, so that we don't even have to think about the temporary files anymore!
Read the article further to get the complete steps of the process:
- Creating the Script
- Running the script
- Automation using Task Scheduler
Creating the script
Open notepad and type the following into it.
@echo off
cd /D %temp%"
rd . /s /q
- Note:
- Make sure that you type everything correctly or else it will have everything messed up!!!!
Save this file as cleaner.bat in a place where you can easily find it. We recommend you to save this file in your Desktop.
Now, let's check if we have any files and folders present in our temp folder.
So, for that, open the Run window by pressing + R and there type %temp% and press Enter.
It will open up the temporary folder in your computer, and generally it will contain lots of folders and files.
The path of the temporary folder will something like
C:\Users\{username}\AppData\temp
If somehow you don't have anything present there, them probably you have opened a wrong folder, or you might have cleared the temporary files recently.
So, in case you have your temporary folder empty, just create some folders and files there and copy some useless files in it, so that you can see the results.
Now, go to the place where you have saved your cleaner.bat file, and then double click to run it. It will flash a black screen for a moment, and will clean all the temporary files present in the temp folder.
Now, go to the temp folder that we've opened above by opening Run window. You'll see that there is nothing present there!
Our script just cleaned everything up!
If somehow you see a few things left, then probably those files are locked and being used in some process. I'll recommend you to run the script each time you power on your computer.
Let's see how to configure Windows to run the script automatically!
Automation using Task Scheduler
Hitb
Very nice
ReplyDeleteI like it too much