Archive for the ‘windows slops’ Category

temporary folders in windows don't have much sense of time

July 2, 2009

temp-clean

It is true that since XP in windows there is a tool called Disk Cleanup. Personally I think Disk Cleanup is stupid. It takes too long to show me what I can delete and what not, and too many seconds of my life to then actually do it. So it’s been a long time that I came with a different solution, at least for the infamous temporary folders (such as c:\windows\temp, and yes there’s more than one) that are usually filled with crap that doesn’t seem to be temporary at all.

I created a batch file that safely does everything with a double click. Here’s the content:

@ECHO OFF
TITLE Temporary Directories Cleaner by ico - code.italyisfalling.com
IF %TMP% == %TEMP% (
IF EXIST %TEMP% ( RMDIR /Q /S %TEMP%
IF NOT EXIST %TEMP% MKDIR %TEMP%
SET message1="%TEMP%" directory emptied.)
)ELSE (
IF EXIST %TEMP% ( RMDIR /Q /S %TEMP%
IF NOT EXIST %TEMP% MKDIR %TEMP%
SET message1="%TEMP%" directory emptied.)
IF EXIST %TMP% ( RMDIR /Q /S %TMP%
IF NOT EXIST %TMP% MKDIR %TMP%
SET message2="%TMP%" directory emptied.)
)
IF EXIST %SystemRoot%\TEMP ( RMDIR /Q /S %SystemRoot%\TEMP
IF NOT EXIST %SystemRoot%\TEMP MKDIR %SystemRoot%\TEMP
SET message3="%SystemRoot%\TEMP" directory emptied.)
CLS
ECHO.
ECHO %message1%
IF EXIST /I %message2% ECHO %message2%
ECHO %message3%
ECHO.
ECHO All done.
pause
EXIT /B

Seems complicated but it is simple. It uses variables so it doesn’t matter where your temporary folders are. The script deletes and recreates your temp folders, although this happens only in the intentions because files that are being used in the folders prevent the deletion. Anyway it works and it is fast… It will wipe your temporary folders clean. Don’t be worried for files that Windows might be using, those won’t be touched simply because they’re opened by the system.

So, if you want to use it yourself, provided that I am not responsible for what you make of it, you know the drill. Copy the code above in a text file and save it as something.cmd on your desktop or wherever you want. Make a shortcut and make sure the file will always be “Run as administrator”.

Let me know if you liked this thing.

p.s. If you happen to host the Firefox cache in one of your temporary folders, you should know that Firefox won’t be very happy to have its cache wiped out by an external application such as this. After having run the batch file, also empty the Firefox cache from the browser, even though it will be empty already. Otherwise the websites you have on your tabs will start looking very funny.