0

我使用了关于如何做我想做的事情的提示,但我有一个困难,以“!”开头的文件夹 例如: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
4

1 回答 1

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
于 2013-09-20T13:56:21.670 回答