title: How to rename files with sequential even and odd numbers in PowerShell?
body: <p>I would like to know how I can rename the files from a specific folder with a sequence of only even and odds numbers in PowerShell. E.g. Folder1: <code>pag_001.jpg, pag_003.jpg, pag_005.jpg.... pag_201.jpg</code> , Folder2: <code>pag_002.jpg, pag_004.jpg, pag_006.jpg.... pag_200.jpg</code>. It is because I have a document that was scanned first the odds pages and secondly the even pages, therefore their file names are in a consecutive sequence from 1 to 201. Then I separated one half of the files which are the odds pages in a new place: <code>Folder1</code>, and the second half,the even pages in the <code>Folder2</code>. That is why I would like change the names first and the join again together with their new names.</p>
  
  <p>I have tried this based in a <a href="https://stackoverflow.com/questions/18304025/bulk-renaming-of-files-in-powershell-with-sequential-numeric-suffixes">similar post</a>: </p>
  
  <p>At the moment I could generate even number sequences like that:</p>
  
  <pre><code>ForEach ($number in 1..100 ) { $number * 2}
  </code></pre>
  
  <p>and odd numbers like that:</p>
  
  <pre><code>ForEach ($number in 0..100 ) { $number *2+1}
  </code></pre>
  
  <p>and wanted apply the sequences generated before to rename my files like that:</p>
  
  <pre><code>cd C:\test\Folder1
  $i = $number * 2
  Get-ChildItem *.jpg | %{Rename-Item $_ -NewName ('pag_{0:D3}.jpg' -f $i++)}
  </code></pre>
  
  <p>but it doesn't works!  Any suggestions are welcome</p>
  
  <p>Regards,</p>