XML Lua PowerShell Script

I got tired of comparing files to my xml.. So I wrote this to make it easier.

Save it as a ps1 file.

XML for Loading Lua Files

Code: Select all

New-Item Load_XML.xml -Force
Add-Content Load_XML.xml `<Ui>
$files = Get-ChildItem –name *.lua
foreach ($file in $files) {Add-Content Load_XML.xml `t`<Script` file=`"$file`"/>}
Add-Content Load_XML.xml `</Ui>
Clean Up:
Converts FIles to UTF8 without BOM Format, Removes Trailing Spaces / Tabs

Code: Select all

Get-ChildItem -Recurse *.lua, *.xml, *.toc | ForEach-Object {
  $contents = [IO.File]::ReadAllText($_) -replace '`r`n', '`n' -replace '`r', '`n' -replace  '`t`n', '`n' -replace  '` `n', '`n'
  $utf8 = New-Object System.Text.UTF8Encoding $false
  [IO.File]::WriteAllText($_, $contents, $utf8)