Skip to content

Instantly share code, notes, and snippets.

@pizycki
Created April 27, 2021 13:10
Show Gist options
  • Save pizycki/b69b08b44c2d0a702891a27fe3f5f8d5 to your computer and use it in GitHub Desktop.
Save pizycki/b69b08b44c2d0a702891a27fe3f5f8d5 to your computer and use it in GitHub Desktop.
Replace text in many files
$rootDir = "C:\Users\pawel\dev\blabla"
$majorVersion = "42"
Get-ChildItem $rootDir -File -Recurse `
| Where-Object { $_.Name -match ".(csproj|cs|nuspec|config)$" } `
#| % { write $_.FullName }
| ForEach-Object {
$content = Get-Content -Encoding utf8 $_.FullName
$content = $content.Replace("Namespace.VX", "Namespace.V$($majorVersion)")
Set-Content -Encoding utf8 $_.FullName $content
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment