Last active
October 3, 2024 09:27
-
-
Save anth12/6a4f076d021113482127 to your computer and use it in GitHub Desktop.
Replaces all instances (file name and contents) of 'X' with 'Y'. Used for template project config.
This file contains 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
$match = Read-Host "What would you like to replace?" | |
$replacement = Read-Host "And what would you like '"$match"' replacing with?" | |
$files = Get-ChildItem $(get-location) -filter *$match* -Recurse | |
$files | | |
Sort-Object -Descending -Property { $_.FullName } | | |
Rename-Item -newname { $_.name -replace $match, $replacement } -force | |
$files = Get-ChildItem $(get-location) -include *.cs, *.csproj, *.sln, *.js, *.scss, *.cshtml, *.razor, *.prompty -Recurse | |
foreach($file in $files) | |
{ | |
((Get-Content $file.fullname) -creplace $match, $replacement) | set-content $file.fullname | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment