Created
January 11, 2014 03:43
-
-
Save chetan/8366728 to your computer and use it in GitHub Desktop.
Handy script for cleaning up old temporary files on windows. ReportQueue (from error reporting) gets especially large...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
IF EXIST c:\windows\temp\ ( | |
forfiles /p "C:\Windows\Temp" /s /m *.* /D -7 /C "cmd /c del /Q @path" | |
) | |
IF EXIST "C:\Users\" ( | |
for /D %%x in ("C:\Users\*") do ( | |
forfiles /p "%%x\AppData\Local\Temp" /s /m *.* /D -7 /C "cmd /c del /Q @path" | |
forfiles /p "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files" /s /m *.* /D -7 /C "cmd /c del /Q @path" | |
forfiles /p "%%x\AppData\Local\Microsoft\Windows\WER\ReportQueue" /s /m *.* /C "cmd /c del /Q @path" | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/50902/how-do-i-delete-old-files-from-a-directory-while-keeping-the-most-recent-ones-on
http://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days
http://ss64.com/nt/forfiles.html