Friday, June 20, 2025

Cleaning Windows temp folder

As my SSD gets more and more stuffed, I’m searching for ways to remove the cruft from it. It’s a Windows 10 installation from 2018, which I have a feeling that it needs a fresh formatted install. But since I cannot afford that now, I just keep going.

Cleaning the temp folder manually is a cumbersome chore and also takes a lot of time. The batch script below, in the other hand, deletes all the files instantly:

@echo off

call :DelRecu "%temp%"
call :DelRecu "%appdata%\Code\Cache"
call :DelRecu "%appdata%\Code\CachedData"
call :DelRecu "%appdata%\Code\Code Cache"
call :DelRecu "%appdata%\Code\GPUCache"
call :DelRecu "%appdata%\Code\logs"
call :DelRecu "%appdata%\Code\User\workspaceStorage"
call :DelRecu "%localappdata%\Battle.net\BrowserCaches\73131118\Cache\Cache_Data"
call :DelRecu "%localappdata%\Battle.net\Logs"

pause
goto :eof

:DelRecu
set FOLDER="%~1"
REM echo Cleaning: %FOLDER%
del /s /f /q %FOLDER%\*
for /f %%f in ('dir /ad /b %FOLDER%\') do rd /s /q %FOLDER%\%%f
REM echo --
goto :eof

A double click on the clean.bat file now can be done at any time, in no time.

No comments: