title: Powershell rename using variable
body: <p>Hi am not able to rename a file using the below code. Please help me on this</p>
  
  <pre><code>    $date = Get-Date -format "yyyyMMdd"
      $path='D:\Users\user\Desktop\Working\'
      $fn = $path+'xxx_'+$date+'.txt'
      $tn = $path+'yyy'+$date+'.dat'
      Rename-Item -Path $fn -NewName $tn
  </code></pre>
  
  <p>Am getting the below error.</p>
  
  <blockquote>
    <p>Rename-Item : Cannot process argument because the value of argument "path" is not valid. Change the value of the
    "path" argument and run the operation again.
    At line:1 char:1
    + Rename-Item -Path $fn -NewName $tn
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Rename-Item], PSArgumentException
        + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RenameItemCommand</p>
  </blockquote>