@echo off setlocal EnableExtensions if "%~1"=="" ( echo Usage: %~nx0 "C:\path\to\project" exit /b 1 ) for %%I in ("%~1") do set "ROOT=%%~fI" if /i "%ROOT%"=="%SystemDrive%\" ( echo Refusing to scan the drive root. exit /b 1 ) if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%" if not exist "%ROOT%\" ( echo Folder not found: %ROOT% exit /b 1 ) pushd "%ROOT%" || ( echo Cannot open folder: %ROOT% exit /b 1 ) echo Build folders bin and obj under %ROOT%: for /d /r %%D in (bin obj) do @echo %%D echo. set "ANSWER=" set /p ANSWER=Delete these folders? Type YES to continue: if /i not "%ANSWER%"=="YES" ( echo Cancelled. Nothing deleted. popd exit /b 0 ) for /d /r %%D in (bin obj) do ( if exist "%%D\" ( echo Deleting %%D rd /s /q "%%D" 2>nul ) ) popd echo Done. Rebuild the project when needed. exit /b 0