批量显示 xml 文件的最新版本

Show the last version of a xml file in batch

在一个目录中,我有一些以下格式的文件:
file_1_v1.xml
file_1_v2.xml
file_1_v3.xml
file_2_v1.xml
file_2_v1.xml
other_files.txt
其他目录
我只想提取最高版本的 xml 文件,在本例中为 file_1_v3.xml 和 file_2_v1.xml。 我知道文件的名称,在本例中为 file_1 和 file_2

@echo off
setlocal
:nextName
   for %%a in ("%~1*.xml") do set "lastFile=%%a"
   echo Last version of %1 is %lastFile%
   shift
if "%~1" neq "" goto nextName

例如:

test.bat file_1 file_2