I run automated UI test with Selenium (unit testing will do this as well, though not as many files) from the Visual Studio Test Explorer a lot. This creates a new folder inside of my solution location named TestResults for every test run. Depending on what I need to deploy for the test (Selenium chrome driver, images, dlls, etc) the size of that it takes up on my hard drive gets very large after a few weeks. I’ve deleted gigs before.
In the spirit of “if you do something more than once, automate it”, I created a batch file and scheduled it with Windows Task Scheduler to run ever day. Just change the folder path below and you can do the same thing.
@echo off
REM cleanup the test results folder
set folder="C:\tfs\MyProject\TestResults"
IF EXIST %folder% (
echo %folder% exists
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
) else (
echo %folder% does not exist
)