I should start off by saying that I am still a beginner in powershell scripting.
I am trying to rename all files recursively in a directory by replacing a "+" with a " " in the file name.
The command I use is: Get-ChildItem -File -Recurse | Rename-Item -NewName {$_.name -replace "+", " "}
but doesn't work and gives me the following error:
Instead if I do this: Get-ChildItem -File -Recurse | Rename-Item -NewName {$_.name -replace "a", " "}
everything works well.
I think the problem is with the "+" character but can't find anything on the web that tackles this problem. Does anyone know how to represent it or how to solve this?
You must escape the plus sign and the command should work:
Get-ChildItem -File -Recurse | Rename-Item -NewName {$_.name -replace "\+", " "}