I need to remove the same html code from many files. I tried to write an powershell script but its not working.
$htmlFiles = Get-ChildItem . *.html -rec
$old = '<form method="GET" action="http://localhost/index.php" name="head2">`r`n
<input type="hidden" name="akcja" value="szukaj">`r`n
<input type="hidden" name="ind" value="0" >`r`n
`r`n
<table border="0" cellpadding="1" cellspacing="0" style="margin-left:11px" >`r`n
`r`n
SOME MORE CODE
`r`n
</table>`r`n
`r`n
</form>'
$new = ""
foreach ($file in $htmlFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace $old, $new} |
Set-Content $file.PSPath
}
I used so much `r`n because i have this same in html files. Maybe I need to do this with regex but regex for over 50 lines is too much for me. I think script is not working because whitespaces doesnt match. How to make it work?
My script runs but with no effect on a files ps. it needs to work on windows