User Tools

Site Tools



Clean Temp Directory

Any windows machine will fill up with temporary files, and many applications do not clean up after themselves very well. The following batch file will delete all files older than 30 days in your personal temp folder.

echo off
echo "Cleaning out Windows Temp folder"
forfiles /p %temp% /s /m *.* /D -30 /C "cmd /c echo @PATH" 2>nul || goto NoFiles
choice /m "Ready to delete these files? " /t 10 /d n
if ErrorLevel 2 goto No
if errorlevel 1 goto Yes
goto End
echo No files found
goto end
echo Aborted
goto End
forfiles /p %temp% /s /m *.* /D -30 /C "cmd /c del @PATH"
echo Files Deleted

Windows System Temp Folder

I haven't discovered a way to auto clean c:\windows\temp. Instead, I manually have to (as an administrator) open the directory, then select everything before a certain date and delete them. NOTE: reboot recommended after this.

microsoft_windows/cleantemp.txt · Last modified: 2017/10/17 18:41 by rodolico