I have to determine the latest release version from a release location containing release artifacts. Here is how the folder looks like:-
1.4
1.4.1
1.5
1.5.1
1.5.2
latest
In the above example my script should return 1.5.2. The release engineer creates a folder called latest and puts the latest release artifacts (1.5.2's contents in the above case) inside it - so I have a easy way to copy the latest release. But my problem is I want to print the version as well. here's my attempt:-
@echo off
SET Remote="\\path to release location"
SET newest=""
for /f %%a in ('dir %Remote% /b /od') do (if NOT %%a=="latest" SET newest=%%a)
echo %newest%
This works fine with the above example. But the release engineer sometimes creates a tmp or some other folder there (basically he forgets to clean up) and that screws up my naive assumption of filtering out just "latest". Is there a easy way to sort the folders that start with a number declare the newest release version.
Also pls suggest if there are any better idea of solving this
findstr /r "^[0-9][0-9]*\.[0-9][0-9]*"latestdirectory too!for /f %%a in ('dir %cd% /b /od ^| findstr /r "^[0-9][0-9]*\.[0-9][0-9]*"') do (SET newest=%%a)@Compo: Thanks for your tip !