Last active
July 26, 2022 21:41
-
-
Save dhmacher/4ed506ab1e369b5b582123209900d599 to your computer and use it in GitHub Desktop.
Validate all image URLs in a WordPress blog export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Export your WordPress blog to an XML file. Then: | |
$xmlFile = "./export/sqlsundaycom.wordpress.2021-05-23.001.xml" | |
$matches = Select-String -Path $xmlFile -Pattern '(?<=src\=\")http(.*?)(?=\")' -AllMatches ` | |
| % { $_.Matches } | |
| % { $_.Value } | |
| Sort-Object -Unique | |
foreach ($url in $matches) { | |
#$url | |
$res = Invoke-WebRequest -Uri $url -Method "HEAD" -SkipHttpErrorCheck | |
if ($res.StatusCode -ne 200) { | |
Write-Error ("ERROR: Status "+$res.StatusCode+": "+$url) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment