我正在尝试列出不以单词“patch”结尾的目录中的最新文件夹
for /f "tokens=*" %%a in ('dir /b /od') do (
// some if loop to ensure that newest is not set to something that ends with "-patch".
set newest=%%a
)
我正在尝试列出不以单词“patch”结尾的目录中的最新文件夹
for /f "tokens=*" %%a in ('dir /b /od') do (
// some if loop to ensure that newest is not set to something that ends with "-patch".
set newest=%%a
)
尝试这个:
for /f "delims=" %%a in ('dir /b /od /ad ^|findstr /evi "patch" 2^>nul') do set "RecentFolder=%%~a"
echo %RecentFolder%
for /f "delims=" %%a in ('dir /b /s /o-d /ad ^|findstr /v /e /c:"-patch" 2^>nul') do (
set "newest=%%~fa"
goto :break
)
:break
echo newest : %newest%
setlocal enableextensions
for /f "tokens=*" %%a in ('dir /b /od') do (
set "a=%%a"
if /i not "!a:~-5!"=="patch" set "file=%%a"
)
file
将包含所需的文件夹名称。