@echo off
setlocal
set "workdir=C:\orbis32\"
set "folder="
for /f "tokens=* delims=" %%i in ('dir %workdir% /AD /B /TW /O-D') do (
set "folder=%%~fi"
goto :break
)
:break
echo newest... %folder%
for /f "skip=1 tokens=* delims=" %%i in ('dir %workdir% /AD /B /TW /O-D') do (
echo rd /s /q "%%~fi"
)
pause
现在我需要从中排除一个特定的文件夹(orbis32 \ logs)但我目前卡住了
答案 0 :(得分:0)
无需先找到最新的文件夹(顺便说一句:它可能是logs
文件夹) - skip
就足够了。只需从obis32\logs
命令中过滤出dir
行:
@echo off
setlocal
set "workdir=C:\orbis32\"
set "folder="
for /f "skip=1 delims=" %%i in ('dir %workdir% /AD /B /TW /O-D ^|find /i /v "orbis32\logs"') do (
echo rd /s /q "%%~fi"
)
pause