Here is a Batch file that will perform two things:

  • Delete Empty Directories
  • Delete files in your TEMP folders (XP, Vista)

Please use with caution =)

@ECHO off
cls
:start
ECHO.
ECHO 1. List Directories.
ECHO 2. Delete Empty Directories.
ECHO 3. Clean TEMP files XP.
ECHO 4. Clean TEMP Files VISTA.
ECHO 5. Exit
set choice=
set /p choice=Type your choice here..
if not ‘%choice%’==” set choice=%choice:~0,1%
if ‘%choice%’==’1’ goto 1
if ‘%choice%’==’2’ goto 2
if ‘%choice%’==’3’ goto 3
if ‘%choice%’==’4’ goto 4
if ‘%choice%’==’5’ goto end
ECHO “%choice%” is not valid please try again
ECHO.
goto start

:1
dir /aD /s /b %SYSTEMDRIVE% | sort /r >%systemdrive%\Directories.txt
%systemdrive%\Directories.txt
goto start

:2
for /f “delims=” %%i in (‘”dir /ad /b /s %SYSTEMDRIVE% | sort /R”‘) do @rmdir “%%i”
@echo all done
goto start

:3
del “%USERPROFILE%\Cookies\*.*” /Q
del “%USERPROFILE%\temp\*.*” /Q
del “%USERPROFILE%\Local Settings\Temp\*.*” /F /Q
del “C:\Temp\*.*” /Q
del “%SYSTEMROOT%\Temp\*.*” /Q
del “%SYSTEMROOT%\Prefetch\*.*” /Q
@ECHO Done!
goto start

:4
del “%USERPROFILE%\Cookies\*.*” /Q
del “%USERPROFILE%\AppData\Local\Temp\*.*” /Q /F
del “%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*” /Q /F
del “%USERPROFILE%\AppData\Local\Microsoft\Windows\History\*.*” /Q /F
del “%SYSTEMROOT%\Temp\*.*” /Q
del “%SYSTEMROOT%\Prefetch\*.*” /Q
@ECHO Done!
goto start

:end
exit

Advertisements