Windows batch dir命令获取以字符串开头的最后修改目录 [英] windows batch dir command get last modified directory starting with string
本文介绍了Windows batch dir命令获取以字符串开头的最后修改目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取Windows批处理文件中以字符串stringEx...
开头的最后修改目录.
I want to get the last modified directory starting with a string stringEx...
in a windows batch file.
例如:我有一个包含如下子目录的文件夹:
For example: I have a folder containing sub-directories like this :
- Directory
-Subdirectory1
-Subdirectory2
-Anothersubdirectory
....
我尝试过此操作,但不起作用:
I tried with this but it doesn't work:
@echo off
Setlocal EnableDelayedExpansion
Set foundedFolder
FOR /F %%i IN ('dir C:\Directory | subtsr "Anoth*" /b /ad-h /od') DO (SET a=%%i)
%foundedFolder%=%a%
有什么想法吗?
推荐答案
for /f "delims=" %%a in ('dir /b /ad-h /od "Anoth*"') do set "latestDir=%%~a"
echo(%latestDir%
这篇关于Windows batch dir命令获取以字符串开头的最后修改目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文