Hi @Suzana Eree ,
please try this (last try for today):
$sourcedir = "./Junk/1"
$resultsdir = "./Junk/2"
Get-ChildItem -Path $sourcedir -Filter *.html | ForEach-Object {
$content = Get-Content -Path $_.FullName -Raw
$replaceValue = ((Select-String -Pattern "(BEBE).+(NERO)" -InputObject $content).Matches.Value).Split(" ")[1]
$findReplacement = Select-String -Pattern "(OANA).+(BOGDAN)" -InputObject $content
$split = ($findReplacement.Matches.Value).Split(" ")
$i = 0
do {
$findBogdan = $split[$i]
$i++
} until ($findBogdan -eq "BOGDAN")
$replacementValue = ($split[1..($i - 2)]) -join ' '
$content.Replace("$replaceValue", "$replacementValue") | Out-File -FilePath $resultsdir\$($_.name)
}
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten