Hi,
Please see if this works.
$sourcedir = "C:\Folder2\"
$resultsdir = "C:\Output\"
Get-ChildItem -Path $sourcedir -Filter *.html | ForEach-Object{
$output=@()
$content = Get-Content -Path $_.FullName
$start = $content | Where-Object {$_ -match '<!-- ARTICOL START -->'}
$final = $content | Where-Object {$_ -match '<!-- ARTICOL FINAL -->'}
for($i=0;$i -lt $content.Count;$i++){
if(($i -gt $content.IndexOf($start)) -and ($i -lt $content.IndexOf($final))){
if($content[$i] -notmatch '<p class='){
continue
}
}
$output += $content[$i]
}
$output | Out-File -FilePath $resultsdir\$($_.name)
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.