title: Renaming files using PowerShell gives "Access to path is denied"
body: <p>Again, like any other "Square Bracket" related PowerShell here, I've read many others similar problems. But the thing is, the error codes I get aren't even similar to any of them ("Access Denied"). Which might be why most of those solutions are ineffective.</p>
  
  <p>Basically I want to batch rename files in a folder based on inputs. The problem <em>only</em> arise when you put and execute the .ps1 file on a dir with square brackets (<code>[]</code>). Removing those brackets shows smooth operation.</p>
  
  <p>The important bits of my program:</p>
  
  <pre><code>$Replace = Read-Host -Prompt 'To Replace'
  $New = Read-Host -Prompt 'With'
  
  Get-ChildItem | ForEach-Object { Move-Item -LiteralPath $_.Name $_.Name.Replace("$Replace", "$New") }
  </code></pre>
  
  <p>Meanwhile, I get a bunch of error codes which are similar to one another like this:</p>
  
  <pre>
  Move-Item : Access to the path is denied.
  At D:\[Folder]\BatchReplaceWords.ps1:33 char:36
  + ... ch-Object { Move-Item -LiteralPath $_.Name $_.Name.Replace("$Replace" ...
  +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : PermissionDenied: (C:\Windows\Syst...y.format.ps1xml:FileInfo) [Move-Item], Unauthorized AccessException
      + FullyQualifiedErrorId : MoveFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.MoveItemCommand
  </pre>
  
  <p>More info: Windows 10 with PowerShell version 5.</p>