Skip to content

Instantly share code, notes, and snippets.

@128keaton
Created March 31, 2022 04:00
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 128keaton/a8a9b83d210560d60c852b58e4ed8bec to your computer and use it in GitHub Desktop.
Save 128keaton/a8a9b83d210560d60c852b58e4ed8bec to your computer and use it in GitHub Desktop.
Powershell scripts used to help manage a collection of Wii games
$currentISOs = Get-ChildItem -Path .\iso -Name -Include *.iso
$currentRZVs = Get-ChildItem -Path .\rvz -Name -Include *.rvz
$dolphinToolPath = "..\Dolphin-x64\DolphinTool.exe"
$totalConverted = 0
foreach ($rvz in $currentRZVs)
{
$iso = $rvz -replace '.rvz', '.iso'
if ($currentISOs -eq $null -or !$currentISOs.Contains($iso)) {
Write-Host "Converting " -NoNewline
Write-Host $rvz -NoNewline -ForegroundColor Red
Write-Host " to " -NoNewline
Write-Host $iso -ForegroundColor Cyan
$output = "$(Get-Location)\iso\$iso"
$input = "$(Get-Location)\rvz\$rvz"
Start-Process -FilePath $dolphinToolPath -ArgumentList "convert -i `"$input`" -o `"$output`" -f iso" -RedirectStandardError iso-err.txt -WindowStyle hidden -Wait
Write-Host "Converted $iso!" -ForegroundColor Green
$totalConverted++
}
}
Write-Host "$totalConverted converted" -BackgroundColor Green -ForegroundColor Black
$currentISOs = Get-ChildItem -Path .\iso -Name -Include *.iso
$currentWBFSs = Get-ChildItem -Path .\wbfs -Name -Include *.wbfs
$wbfsToolPath = ".\wbfs_file.exe"
$totalConverted = 0
$saveSpace = True
foreach ($iso in $currentISOs)
{
$wbfs = $iso -replace '.iso', '.wbfs'
if ($currentWBFSs -eq $null -or !$currentWBFSs.Contains($wbfs)) {
Write-Host "Converting " -NoNewline
Write-Host $iso -NoNewline -ForegroundColor Red
Write-Host " to " -NoNewline
Write-Host $wbfs -ForegroundColor Cyan
$output = "$(Get-Location)\wbfs\$wbfs"
$input = "$(Get-Location)\iso\$iso"
Start-Process -FilePath $wbfsToolPath -ArgumentList "`"$input`" convert `"$output`"" -RedirectStandardError wbfs-err.txt -WindowStyle hidden -Wait
Write-Host "Converted $wbfs!" -ForegroundColor Green
if ($saveSpace) {
Remove-Item "$input"
$emptyISO = New-Object System.IO.FileStream $input, Create, ReadWrite
$emptyISO.SetLength(1KB)
$emptyISO.Close()
}
$totalConverted++
}
}
Write-Host "$totalConverted converted" -BackgroundColor Green -ForegroundColor Black
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment