title: I want to rename the extension of a few files with extension in powershell
body: <p>I want to change the extension of a few files from .cap to .zip. I wrote following code in powershell:</p>
  
  <pre><code>Copy-Item $sourceFileLocation\*.cap $Temp -Force
  </code></pre>
  
  <p>But what if the same files with .zip extension already exist?
  It gives the following error on the console:</p>
  
  <pre><code>Rename-Item : Cannot create a file when that file already exists.
  At E:\ExtractHashId.ps1:32 char:23
  +     dir $Temp\*.cap | Rename-Item -NewName{$_.Name -replace ".cap", ".zip"}
  +                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : WriteError: (C:\Users\v-kamo...News_Locals.cap:String) [Rename-Item], IOException
      + FullyQualifiedErrorId : RenameItemIOError,Microsoft.PowerShell.Commands.RenameItemCommand
  </code></pre>
  
  <p>So What I need to do to overwrite these files?</p>