Batch file to delete temporary files and clean recycle bin:
Today we are living in computer age. It has dominated almost all the fields and plays a very vital role in almost all the industries like banks, factories, educational institutes and organizations, research and development centres, homes, designing and engineering sector etc. and also lead to a very fast growth in industrial revolution and technology. So we all should atleast know how to operate a computer and know some simple tricks and ways to make it run faster and get better results or outputs from it.
So today I will discuss with you, how we can delete internet temporary files, temporary files and other unnecessary items from our computer with the help of a batch file, which will do this all automatically for us just by running it, because batch file is made of a single or multiple commands designed to automate work for us. Batch files normally have extensions .bat and .cmd and run on a windows operating system and when they get executed, they open a command prompt window and execute commands those are mentioned in batch files, run in this window.
In our previous post, we had discussed that how to make a PC perform faster and discussed various ways to do this. So in today’s topic we will discuss how to clean the PC or clean temp and other unnecessary data (that we don’t require but it gets automatically created when we do activities in our computer system), with the help of a batch file, that will do this automatically for us. otherwise we need not to open each folder and delete its contents, but batch file will do this for us, we just need to add some commands to it and run it.
So let us start with our today’s activity.
First of all open a notepad, just by pressing Wiindows logo and R key at same time from your keyboard, run command will be opened before you, type here notepad and hit enter or press ok (as this is one of the ways to open a notepad).
Then copy the whole test mentioned below and paste this in already opened notepad (from @echo off to :END).
if %os%==Windows_NT goto WINNT
echo .Using a Windows NT based system
echo Deleting Temporary Internet Files
del /q /f /s “%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*”
del /q /f /s “%USERPROFILE%\AppData\Local\Microsoft\Windows\INetCache\*.*”
del /q /f /s “%temp%\*.*”
echo Deleting Prefetch folder data
del /q /f /s “%systemroot%\Prefetch\*.*”
echo Deleting Temp folder data
del /q /f /s “%systemroot%\Temp\*.*”
echo Deleting Cookies
del /q /f /s “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Cookies\*.*”
del /q /f /s “%USERPROFILE%\AppData\LocalLow\Microsoft\Internet Explorer\DOMStore\*.*”
echo Deleting History
del /q /f /s “%USERPROFILE%\AppData\Local\Microsoft\Windows\History\*.*”
del /q /f /s “%USERPROFILE%\AppData\Local\Microsoft\Internet Explorer\Recovery\Active\*.*”
del /q /f /s “%USERPROFILE%\AppData\Local\Microsoft\Internet Explorer\Recovery\Last Active\*.*”
echo Deleting Windows Internet Explorer Dat Files
del /q /f /s “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\PrivacIE\*.*”
del /q /f /s “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\IECompatCache\*.*”
del /q /f /s “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\IETldCache\*.*”
echo Deleting Windows Error Reporting Files
del /q /f /s “%USERPROFILE%\AppData\Local\Microsoft\Windows\WER\ReportArchive\*.*”
echo Deleting Flash Player Temp Files
del /q /f /s “%USERPROFILE%\AppData\Roaming\Macromedia\Flash Player\*.*”
echo Deleting Remote Desktop Cache
del /q /f /s “%USERPROFILE%\AppData\Local\Microsoft\Terminal Server Client\Cache\*.*”
echo Deleting Profile Temp Files
del /q /f /s “%USERPROFILE%\AppData\Local\Temp\*.*”
echo Deleting FireFox Cache
del /q /f /s “Cache\*.*”
echo Deleting User Profile Adobe Temp Files
del /q /f /s “%USERPROFILE%\AppData\LocalLow\Adobe\Acrobat\9.0\Search\*.*”
del /q /f /s “%USERPROFILE%\AppData\LocalLow\Adobe\Common\Media Cache Files\*.*”
del /q /f /s “%USERPROFILE%\AppData\LocalLow\Adobe\Common\Media Cache\*.*”
echo Deleting User Office Recent Files
del /q /f /s “%USERPROFILE%\AppData\Roaming\Microsoft\Office\Recent\*.*”
echo Deleting User Office TMP Files
del /q /f /s “%USERPROFILE%\AppData\Roaming\Microsoft\Office\*.tmp”
echo Emptying Recycle Bin
del %systemdrive%\$Recycle.bin\*.* /f /s /q
echo Deleting Recent Items
del /q /f /s “%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Recent\*.tmp”
echo Error…Invalid Operating System…
echo Error…No actions were made…
Then close this notepad after saving it with .bat extension. For this, click ‘save as’ in file menu item, choose location where to save (it will be better if you save this in drive other than windows partition), give file a name, I am giving this file a name as cleanpc.bat, and note that save as type option should be selected as all files.
Before running this file, we should take some precautions and use smartness also, because after running this file, the files or data once get deleted from pc, will not be recovered in normal conditions. So please read instructions carefully those are mentioned ahead, before running this file.
Note that it will give better results if before running this file, you close everything on your desktop, no file or no browser or no programs should be running on your computer, other than background programs, applications or services.
Before running the batch file, please check your recycle bin, if you want anything to be restored, restore it, then run batch file, because you will not be able to get that data back in normal conditions, as already mentioned above.
Now run the batch file that you have created and saved on your PC, by double click on it and let it run, don’t do anything, when it will execute all the commands, it will be closed automatically, you need not close it. It will take some time, according to the size of data in your temporary, prefetch and other folders.
Now you can check your recycle bin after running the batch file, it will be cleared, if you see some data in it, then refresh it 2-3 times, it will take effect and there will be no data, you will find your recycle bin clean now.
In this batch file we have used del command with options /q /f /s, we will discuss these options with details:
/q – specifies quiet mode, you will not be prompted for deletion confirmation or it will not ask you to delete the files or objects.
/s – specifies deletion of specified files and all subdirectories from the current directory. Displays the names of the files as they are being deleted.
/f – specifies forcefully deletion of read-only files.
Note: For our more articles or blogs please visit the Blog link of our website.