我使用了一个关于如何做我想要的提示,但是我有一个困难,那些以“!”开头的文件夹。例如:c:\!test
,中间是“。”例如:c:\test.test
未被删除。你能帮帮我吗?
@Echo OFF
echo.
setlocal enabledelayedexpansion
echo Search...
FOR /R %root% %%A IN (.) DO (
if '%%A'=='' goto end
set dir="%%A"
set dir=!dir:.=!
set directory=%%A
set directory=!directory:.=!
set directory=!directory::=!
set directory=!directory:\=;!
for /f "tokens=* delims=;" %%P in ("!directory!") do call :loop %%P
)
:end
echo.
echo Finished.
echo Press any key to exit...
pause >nul
endlocal
exit
:loop
if '%1'=='' goto endloop
if '%1'=='history' (
rd /S /Q !dir!
echo !dir! was deleted.
)
SHIFT
goto :loop
:endloop
答案 0 :(得分:1)
我认为您的代码会检查每个文件夹,如果找到名为history
的文件夹,则会将其全部删除。
如果这是任务,那么这应该做同样的事情。
@echo off
FOR /D /R %root% %%A IN (*) DO if /i "%%~nxA"=="history" if exist "%%A\" rd /s /q "%%A" & echo "%%A" has been deleted