Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Techlogist/b50ed775da158b77835bdf9d0c2fda23 to your computer and use it in GitHub Desktop.
Save Techlogist/b50ed775da158b77835bdf9d0c2fda23 to your computer and use it in GitHub Desktop.
Quickly delete temporary files in Windows 10
REM License: GNU General Public License v2.0
REM Author: Miguel
REM Website: www.techlogist.net
REM Post: https://techlogist.net/batch/quickly-delete-temporary-files-in-windows-10/
REM Description: Quickly delete temporary files in Windows 10
REM OS/Language/Region: Windows/EN-US
@echo off
title Delete Temporary Files Windows 10
color f0
mode con:cols=70 lines=33
goto start
:start
cls
echo.
echo Deleting files…
REM Internet temp. file locations
set _inet_cache=C:\Users\%username%\AppData\Local\Microsoft\Windows\INetCache\IE
forfiles /P "%_inet_cache%" /M * /C "cmd /c if @isdir==FALSE del @file"
forfiles /P "%_inet_cache%" /M * /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"
REM Application temp. file locations
set _Local_Temp=C:\Users\%username%\AppData\Local\Temp
forfiles /P "%_Local_Temp%" /M * /C "cmd /c if @isdir==FALSE del @file"
forfiles /P "%_Local_Temp%" /M * /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"
REM Windows temp. file locations
set _windows_temp=C:\Windows\Temp
forfiles /P "%_windows_temp%" /M * /C "cmd /c if @isdir==FALSE del @file"
forfiles /P "%_windows_temp%" /M * /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"
REM Windows Update temp. file locations
set _updates=C:\Windows\SoftwareDistribution\Download
forfiles /P "%_updates%" /M * /C "cmd /c if @isdir==FALSE del @file"
forfiles /P "%_updates%" /M * /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"
REM Explorer Icon temp. file locations
set _explorer=C:\Users\%Username%\AppData\Local\Microsoft\Windows\Explorer
forfiles /P "%_explorer%" /M * /C "cmd /c if @isdir==FALSE del @file"
forfiles /P "%_explorer%" /M * /C "cmd /c if @isdir==TRUE rmdir /S /Q @file"
REM Empty recycle bin
rd /s /q "c:\$Recycle.Bin"
goto done
:done
cls
echo.
echo All deleted!
echo.
echo.
echo Press any key to leave.
pause>nul
:exit
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment