Skip to content

Instantly share code, notes, and snippets.

@prodriguezr
Created August 23, 2021 16:20
Show Gist options
  • Select an option

  • Save prodriguezr/4cd349faa5c4244b485744f111cad677 to your computer and use it in GitHub Desktop.

Select an option

Save prodriguezr/4cd349faa5c4244b485744f111cad677 to your computer and use it in GitHub Desktop.
Replace text in multiple files in a folder with PowerShell
$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