Saturday, January 8, 2011

Batch File To Clean Temp Folder

There is a lot of utilities for Windows designed especially for cleaning temporary files in Windows Temp folder and some other places where they usually can be found. Some of these programs are freeware, some of them are paid. With help of small batch script instead of one of the such utilities you can save your money and some space on HDD. Also this batch script gives you great flexibility: you will be able to add new folders to be cleaned if you need.
The script below cleans folder named 'C:\Temp' and makes it default temp folder for those applications who use the folder given in TEMP variable:
@ECHO Cleaning temporary folder...
DEL /S /Q /F C:\TEMP > NUL
SET TMP=C:\TEMP
SET TEMP=C:\TEMP
SET PKTMP=C:\TEMP
@ECHO Temporary folder is cleaned
If you want to clean also Windows default temp folder, you should also add line with 'DEL' for 'c:\Documents and Settings\Your User Name\Local Settings\Temp' (for Windows XP). Of course, the simplest way to modify this batch script is using Dr.Batcher.

No comments:

Post a Comment

Translate