Skip to content

Instantly share code, notes, and snippets.

@joshbtn
Created December 4, 2014 17:04
Show Gist options
  • Save joshbtn/e8f976e0ab7e98d3f54d to your computer and use it in GitHub Desktop.
Save joshbtn/e8f976e0ab7e98d3f54d to your computer and use it in GitHub Desktop.
Find and replace
#Find and replace
$fileNameMatch = "\.html|\.txt"
$find = ""
$replace = ""
$webFiles = get-childitem . -Recurse | Where-Object {$_.Name -match $fileNameMatch}
foreach ($file in $webFiles)
{
Write-Host $file
(Get-Content $file.PSPath) |
Foreach-Object {$_ -replace $find, $replace} |
Set-Content $file.PSPath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment