C tips for quickly deleting the bin and obj folders

  • 2020-05-17 06:14:52
  • OfStack

Here is the batch code:

@echo off
set nowPath=%cd%
cd \
cd %nowPath%

::delete specify file(*.pdb,*.vshost.*)
for /r %nowPath% %%i in (*.pdb,*.vshost.*) do (del %%i)

::delete specify folder(obj,bin)
for /r %nowPath% %%i in (obj,bin) do (IF EXIST %%i RD /s /q %%i)

echo OK
pause

Note:
1. In batch processing, the beginning of two semicolons means to comment out the line
2. Copy the above code into notepad and name the file with the bat suffix, such as clear.bat.
3. clear.bat is best placed in the directory (or upper level directory) where the delete operation is to be performed.

If you just want to delete a file, you can remove the sentence for /r %nowPath% %%i in (obj,bin) do (IF EXIST %%i RD /s /q %%i), * * pdb,*.vshost.*) in the first sentence of for /r %nowPath% %%i in (*.pdb,*.vshost.*) do (del %%i).


Related articles: