Win32: Fix rm.bat
- `if exist` and `del` ignore directories matching the wildcard, remove both separately. - `rd /s` ignores wildcards, while `del` removes ordinary files by the wildcard, iterate over matching directories by `for /D`.
This commit is contained in:
parent
5fec930832
commit
3cd809deb5
@ -4,12 +4,15 @@ set recursive=
|
|||||||
:optloop
|
:optloop
|
||||||
if "%1" == "-f" shift
|
if "%1" == "-f" shift
|
||||||
if "%1" == "-r" (shift & set "recursive=1" & goto :optloop)
|
if "%1" == "-r" (shift & set "recursive=1" & goto :optloop)
|
||||||
|
if "%1" == "--debug" (shift & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop)
|
||||||
:begin
|
:begin
|
||||||
if "%1" == "" goto :end
|
if "%1" == "" goto :end
|
||||||
set p=%1
|
set p=%1
|
||||||
if exist "%p:/=\%" for %%I in ("%p:/=\%") do (
|
set p=%p:/=\%
|
||||||
del /q "%%I" || if "%recursive%" == "1" rd /s /q "%%I"
|
if exist "%p%" del /q "%p%" > nul
|
||||||
) 2> nul
|
if "%recursive%" == "1" for /D %%I in (%p%) do (
|
||||||
|
rd /s /q %%I
|
||||||
|
)
|
||||||
shift
|
shift
|
||||||
goto :begin
|
goto :begin
|
||||||
:end
|
:end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user