###########################################################
# Untersucht ob alle HTML-Seiten korrekt verlinkt sind.
# Erzeugt ggf. den Link zurück, falls dieser fehlt
# ACHTUNG: Untersucht und ggf. upgedatet werden nur die
# HTML-Seiten, nicht aber die originalen JPG-Dateien!
###########################################################
. .\MyHTML.ps1
$HtmlPath = $env:Work + '\HTML'
Function Get-Links() {
Param(
[String]$FullName
)
Process {
Write-Host "Processing: $FullName"
$SourceName = Split-Path -path $FullName -leaf
$Content = Get-Content $FullName -raw
$Content = ($Content -split 'id="S_A">', 2, 'simplematch')[1]
$S_A = ($Content -split '', 2, 'simplematch')[0]
$S_A = ($S_A -split '', 2, 'simplematch')[0]
$FullDestination = $HtmlPath + '\' + $DestName
if (Test-Path -Path $FullDestination) {
$Content = Get-Content $FullDestination -Raw
$Content = Update-Links -SourceName $SourceName -DestName $DestName -Content $Content
if ($Content.Length -ne 0) {
Set-Content -Path $FullDestination -Value $Content -NoNewline
}
}
else {
Write-Host "Link not found: $FullDestination"
}
$S_A = ($S_A -split '', 2, 'simplematch')[1]
$S_A = ($S_A -split '', 2, 'simplematch')[0]
while ($S_A.Length -ne 0) {
$S_A = ($S_A -split '', 2, 'simplematch')[0]
if ($Link -eq $Sourcename) {
return ''
}
}
$Index = $Content.LastIndexOf('')
$Content = $Content.Substring(0, $Index) + (Write-MyLink -Filename $SourceName) + $Content.Substring($Index)
return $Content
}
}
Get-ChildItem $HtmlPath -File | Where-Object { $_.FullName -match '\.html$' } | `
ForEach-Object { Get-Links $_.FullName }
Pause