-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclean.cmd
More file actions
57 lines (44 loc) · 1.13 KB
/
Copy pathclean.cmd
File metadata and controls
57 lines (44 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@echo off
setlocal enabledelayedexpansion
taskkill /im dotnet.exe /f
set "rootDir=C:\Sources\CleanMyPosts"
set "vsDir=%rootDir%\.vs"
set "testresultDir=%rootDir%\TestResults"
rd /s /q "%vsDir%"
rd /s /q "%testresultDir%"
:: Iterate over all subdirectories under %rootDir%
for /d /r "%rootDir%" %%a in (*) do (
if /i "%%~nxa"=="bin" (
call :DeleteBinObj "%%a" "bin"
) else if /i "%%~nxa"=="obj" (
call :DeleteBinObj "%%a" "obj"
)
)
echo Finished.
REM pause
exit /b
:DeleteBinObj
setlocal
set "currentDir=%~1"
set "skipDelete="
:: Check for .git, node_modules, or _archive in the current directory path
for %%b in ("%currentDir%") do (
for %%c in (".git" "node_modules" "_archive") do (
echo %%b | findstr /i "%%c" >nul
if not errorlevel 1 (
set "skipDelete=yes"
goto :skipDeletion
)
)
)
:skipDeletion
if not defined skipDelete (
if /i "%~2"=="bin" (
echo Deleting folder: "%currentDir%"
rd /s /q "%currentDir%"
) else if /i "%~2"=="obj" (
echo Deleting folder: "%currentDir%"
rd /s /q "%currentDir%"
)
)
endlocal