问题
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%
Any ideas?
回答1:
for /f "delims=" %%a in ('dir /b /ad-h /od "Anoth*"') do set "latestDir=%%~a"
echo(%latestDir%
来源:https://stackoverflow.com/questions/20132814/windows-batch-dir-command-get-last-modified-directory-starting-with-string