-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_encoding.ps1
More file actions
21 lines (17 loc) · 788 Bytes
/
fix_encoding.ps1
File metadata and controls
21 lines (17 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Script to fix UTF-8 encoding in all HTML files
$rootPath = "c:\Users\ablma\Documents\Cerezo\Web\condadodecastilla"
$files = Get-ChildItem -Path $rootPath -Recurse -Filter "*.html"
foreach ($file in $files) {
try {
# Read file content without BOM
$content = Get-Content -Path $file.FullName -Raw -Encoding UTF8
# Write back with UTF-8 without BOM
$utf8NoBom = New-Object System.Text.UTF8Encoding $false
[System.IO.File]::WriteAllText($file.FullName, $content, $utf8NoBom)
Write-Host "Fixed: $($file.Name)" -ForegroundColor Green
}
catch {
Write-Host "Error processing: $($file.Name) - $($_.Exception.Message)" -ForegroundColor Red
}
}
Write-Host "`nEncoding fix complete!" -ForegroundColor Cyan