I have a directory full of .jar files, named progressively like so:
version-1.jar
version-2.jar
version-3.jar
I am trying to select the highest numbered file. Is there any really simple way to do it?
Because doing .\version*.jar causes an error, presumably due to the multiple files?
We need delayed expansion
Just a variable for the maximum:
Then iterate over the files:
We need the file name without extension
And remove the
version-from the start:Now
FNshould contain just the number and we can compare:And we’re done:
The complete batch file: