Get-ChildItem 'C:\Users\Zac\Downloads\script test\script test\*.txt' -Recurse | ForEach {(Get-Content $_ | ForEach { $_ -replace '1000', $fileNameOnly}) | Set-Content $_ }
I have been trying to use a simple PowerShell script to replace the 1000
value in my documents with the goal of replacing the value with the name of the .nc1/.txt
file it is editing.
For example a file that is called BM3333.nc1
has a line value of 1000
which needs to replace it with BM3333
so on, so forth. This will be used in batch editing.
What is the variable that I use for replacing the 1000
with the file name?
So far, I can get this to run but it doesn't replace the 1000
value, it removes it.