title: Rename files with a sequence number on a per-folder basis
body: <p>I need to number the files in a lot of folders.</p>
  
  <p>I used the following:</p>
  
  <pre><code>Get-ChildItem -Recurse -Include *.* | ForEach-Object -Begin { $count = 1 } -Process { Rename-Item $_ -NewName "image_$count.jpg"; $count++ }
  </code></pre>
  
  <p>It works, but the problem is that the numbering is continuing between the folders.</p>
  
  <p>For example:</p>
  
  <pre><code>\folder1
  image_1.jpg
  image_2.jpg
  image_3.jpg
  
  \folder2
  image_4.jpg
  image_5.jpg
  image_6.jpg
  
  ...
  </code></pre>
  
  <p>What I need is to stop the number count when each folder ends and the rename starts from number 1 in the next folder.</p>
  
  <p>Thanks.</p>