I would like to search thru files with .token files that have a string with the following pattern __[characters]__
and perform the following via PowerShell:
For example:
__STAGE__
to
#{STAGE}
I am migrating RM token files to Octopus Deploy and need a clean up step via scripting.
In the most basic way and assuming there's no problem fitting a token file into memory:
$TokenFiles = Get-ChildItem *.token
foreach ($file in $TokenFiles) {
$NewContent = Get-Content $file.FullName -Raw
$NewContent = $NewContent -replace '__(.*?)__', '#{$1}'
Set-Content $file.FullName -Value $NewContent
}