I am trying to use PowerShell do a simple find and replace. Essentially, I used to have some support files in a directory with the same name of a "master" file. All but one of those support files are no longer necessary. The "master" file has a text reference to the path of the other file. What I want to do is modify this path in the "master" file to remove the deleted directory.
For example, let's say I have the file C:\Temp\this+that.txt I used to have C:\Temp\this+that\this+that.dat that has now been moved to C:\Temp\this+that.dat
C:\Temp\this+that.txt has a line like this:
/temp/this+that/this+that.dat
I would like this line to become:
/temp/this+that.dat
I have lots of these files that a batch file is moving. Everything is working fine using the powershell command below for all file names that do NOT contain a plus + sign. For those files, the call below does not work.
powershell -Command "(gc '!CURRENT_FILE!') -replace '/!BASE_NAME!/', '/' | Set-Content '!CURRENT_FILE!'"
For the example above, CURRENT_FILE would be C:\Temp\this+that.txt and BASE_NAME would be this+that
Can anyone help me with why this isn't working for file names that contain a plus + sign?