title: Batch Script to get latest folder
body: <p>I have to determine the latest release version from a release location containing release artifacts. Here is how the folder looks like:-</p>
  
  <pre><code>1.4
  1.4.1
  1.5
  1.5.1
  1.5.2
  latest
  </code></pre>
  
  <p>In the above example my script should return 1.5.2. The release engineer creates a folder called <code>latest</code> 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:-</p>
  
  <pre><code>@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%
  </code></pre>
  
  <p>This works fine with the above example. But the release engineer sometimes creates a <code>tmp</code> 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. </p>
  
  <p>Also pls suggest if there are any better idea of solving this</p>