Created
August 23, 2021 16:20
-
-
Save prodriguezr/4cd349faa5c4244b485744f111cad677 to your computer and use it in GitHub Desktop.
Replace text in multiple files in a folder with PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $filenames = @(get-childitem -Path "<Folder>\*.<Extension>" | % { $_.FullName }) | |
| foreach ($file in $filenames) | |
| { | |
| $replacementStr = '<Replacement string>' | |
| (Get-Content $file) | | |
| Foreach-object { $_ -replace '<String to relace>' , $replacementStr } | | |
| Set-Content $file | |
| Write-Host Processed $file | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment