I’m trying to do a replace in content of all files in a certain directory structure.
get-childItem temp\*.* -recurse |
get-content |
foreach-object {$_.replace($stringToFind1, $stringToPlace1)} |
set-content [original filename]
Can I get the filename from the original get-childItem to use it in the set-content?
Add processing for each file:
Key points:
$filepath = $_.FullName;— get path to file(get-content $filepath)— get content and close fileset-content $filepath -Force— save modified content