-
-
Save matthewjberger/7c026db8e8c29127317e573af8621355 to your computer and use it in GitHub Desktop.
Recursive replace in files (PowerShell)
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
$find = 'jquery-1\.4\.4' | |
$replace = 'jquery-1\.5\.1' | |
$match = '*.cshtml' , '*.vbhtml' | |
$preview = $true | |
foreach ($sc in dir -recurse -include $match | where { test-path $_.fullname -pathtype leaf} ) { | |
select-string -path $sc -pattern $find | |
if (!$preview) { | |
(get-content $sc) | foreach-object { $_ -replace $find, $replace } | set-content $sc | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment