2

我正在尝试列出不以单词“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
)
4

3 回答 3

2

尝试这个:

for /f "delims=" %%a in ('dir /b /od /ad ^|findstr /evi "patch"  2^>nul') do set "RecentFolder=%%~a"
echo %RecentFolder%
于 2013-07-19T13:14:44.300 回答
1
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%
于 2013-07-19T12:35:38.607 回答
0
setlocal enableextensions
for /f "tokens=*" %%a in ('dir /b /od') do (
    set "a=%%a"
    if /i not "!a:~-5!"=="patch" set "file=%%a"
)

file将包含所需的文件夹名称。

于 2013-07-19T12:50:41.363 回答