Here's an example using the existing comments as a base.
This version additionally uses findstr to ensure that the dir
command wildcards actually match single digits.
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
Set "BaseDir=%UserProfile%\Desktop\ABC"
PushD "%BaseDir%" 2>NUL&&(Set "LatestVer=")||Exit /B
For /F Delims^=^ EOL^= %%A In (
'"Dir /B/AD-L/O-N "V?_?_?_win64" 2>NUL|"%__AppDir__%FindStr.exe" /I "V[0-9]_[0-9]_[0-9]_win64""'
)Do If Not Defined LatestVer Set "LatestVer=%%A"&GoTo OpenIt
Echo Latest version directory not found!&"%__AppDir__%Timeout.exe" /T 3 /NoBreak>NUL&Exit /B
:OpenIt
Start "" "%SystemRoot%\Explorer.exe" "%LatestVer%"
The example above assumes by "open" you actually meant in Windows Explorer, so I have included that as a fully qualified command, despite Start "" "%LatestVer%"
also being valid. You may need to adjust that command, as well as the path between the =
and closing "
on line 3
, (to suit your chosen base directory source location).
To read the usage information for the commands used, open a Command Prompt window and enter the command name followed by its help option. e.g.
echo /?
, setlocal /?
, set /?
, pushd /?
, exit /?
, for /?
, dir /?
, findstr /?
, if /?
, goto /?
, timeout /?
and start /?
.