8

I'm trying to write a windows script that will remove every bin and obj folder in my project folder. It just doesn't work..

I found this:

for /d /r . %d in (_svn) do @if exist "%d" rd /s/q "%d"

so I've tried:

for /d /r . %d in (bin) do @if exist "%d" rd /s/q "%d"

but it didn't work. The closest I've been is:

FOR /D %%p IN ("C:\temp\test\*.*") DO rmdir "bin" /s /q

it removes bin folder from first layer, but not in subfolders

Thanks for help

Community
  • 1
  • 1
Ish Thomas
  • 2,270
  • 2
  • 27
  • 57

2 Answers2

12

Like this:

for /d /r . %%d in (bin obj) do @if exist "%%d" rd /s/q "%%d"
voytek
  • 2,202
  • 3
  • 28
  • 44
3
  1. Create an empty file and name it DeleteBinObjFolders.bat
  2. Copy-paste the below code into the DeleteBinObjFolders.bat
  3. Copy the DeleteBinObjFolders.bat file in the same folder with your solution (*.sln) file.
@echo off
@echo Deleting all BIN and OBJ folders...
for /d /r . %%d in (bin obj) do @if exist "%%d" rd /s/q "%%d"
@echo BIN and OBJ folders successfully deleted :) Close the window.
pause > nul
Jens G
  • 17
  • 5
Alper Ebicoglu
  • 8,884
  • 1
  • 49
  • 55