PowerShell is a good choice ;) It is very easy to enumerate files in given directory, read them and process.
The script could look like this:
Get-ChildItem C:\Projects *.config -recurse |
Foreach-Object {
$c = ($_ | Get-Content)
$c = $c -replace '<add key="Environment" value="Dev"/>','<add key="Environment" value="Demo"/>'
[IO.File]::WriteAllText($_.FullName, ($c -join "`r`n"))
}
I split the code to more lines to be readable for you.
Note that you could use Set-Content instead of [IO.File]::WriteAllText
, but it adds new line at the end. With WriteAllText
you can avoid it.
Otherwise the code could look like this: $c | Set-Content $_.FullName
.