title: Batch file to rename and reverse files in a folder
body: <p>I have a folder that contains <code>.jpg</code> images files named with numbers:</p>
  
  <blockquote>
  <pre><code>1.jpg
  2.jpg
  ...
  100.jpg
  </code></pre>
  </blockquote>
  
  <p>How can I reverse the files name so that the last one is the first one, i.e:<br>
  <code>100.jpg</code> becomes <code>1.jpg</code> and so on?</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  
  ::get files count
  set count=0
  for %%x in (*.jpg) do (
   set /a count+=1
  )
  
  ::rename
  for /L %%a in (1,1,%count%) do (
   set /a new=101-%%a
   ren "!new!.jpg" "temp.jpg"
   ren "%%a.jpg" "!new!.jpg"
   ren "temp.jpg" "%%a.jpg"
  )
  endlocal
  </code></pre>
  
  <p>I tried changing the 101 to %count% + 1
  This code don't execute if the total files number are more than 50.</p>
  
  <p>Any help will be appreciated.
  Thanks in advance!</p>