Win32: Rewrite rm.bat

`rd` cannot remove ordinary files, use `del` or `rd` for each entry.
This commit is contained in:
Nobuyoshi Nakada 2024-12-27 16:25:49 +09:00
parent 6be0ae35e8
commit 3a2d1feb1e
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2024-12-27 08:40:39 +00:00

View File

@ -1,18 +1,15 @@
@echo off
setlocal
set recursive=
:optloop
if "%1" == "-f" shift
if "%1" == "-r" (shift & set "recursive=1" & goto :optloop)
if "%recursive%" == "1" goto :recursive
:begin
if "%1" == "" goto :end
set p=%1
if exist "%p:/=\%" for %%I in ("%p:/=\%") do @del "%%I"
if exist "%p:/=\%" for %%I in ("%p:/=\%") do (
del /q "%%I" || if "%recursive%" == "1" rd /s /q "%%I"
) 2> nul
shift
goto :begin
:recursive
if "%1" == "" goto :end
set p=%1
if exist "%p:/=\%" rd /s /q "%p:/=\%"
shift
goto :recursive
:end