Skip to content

Instantly share code, notes, and snippets.

@kiyoaki
Created December 18, 2017 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiyoaki/984cc27fafa6cdad2160440a7939673f to your computer and use it in GitHub Desktop.
Save kiyoaki/984cc27fafa6cdad2160440a7939673f to your computer and use it in GitHub Desktop.
Encode files UTF-8
$dir = "target directory"
Get-ChildItem $dir -Recurse -Include *.cs | Rename-Item -NewName {$_.FullName + ".bkup"}
Get-ChildItem $dir -Recurse -Include *.cs.bkup | ForEach-Object {Get-Content $_.FullName | Out-File -Encoding UTF8 ($_.FullName -replace '.bkup','')}
Get-ChildItem $dir -Recurse -Include *.cs.bkup | del
Get-ChildItem $dir -Recurse -Include *.cshtml | Rename-Item -NewName {$_.FullName + ".bkup"}
Get-ChildItem $dir -Recurse -Include *.cshtml.bkup | ForEach-Object {Get-Content $_.FullName | Out-File -Encoding UTF8 ($_.FullName -replace '.bkup','')}
Get-ChildItem $dir -Recurse -Include *.cshtml.bkup | del
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment