# Extract base domains from problematic_backlinks.csv and write disavow_no_links.txt $in = 'problematic_backlinks.csv' $out = 'disavow_no_links.txt' if (-not (Test-Path $in)) { Write-Error "$in not found"; exit 1 } $lines = Get-Content $in | Where-Object { $_ -and $_.Trim() -ne '' } $hosts = @() foreach ($line in $lines) { if ($line -match '^"([^"]+)"') { $url = $matches[1].Trim() try { $u = [uri]$url $host = $u.Host.ToLower() if ($host.StartsWith('www.')) { $host = $host.Substring(4) } $parts = $host -split '\.' if ($parts.Length -ge 2) { $base = $parts[-2] + '.' + $parts[-1] } else { $base = $host } $hosts += $base } catch { } } } $uniq = $hosts | Sort-Object -Unique # Write disavow file @('# Disavow candidates generated from problematic_backlinks.csv', '# Review before uploading to Google Search Console') | Out-File $out -Encoding utf8 foreach ($d in $uniq) { "domain:$d" | Out-File $out -Encoding utf8 -Append } Write-Output "Wrote $($uniq.Count) domains to $out"