Skip to content

Instantly share code, notes, and snippets.

@milnak
Last active November 23, 2023 20:10
Show Gist options
  • Save milnak/e77335e0e1a88664a820966c342eef00 to your computer and use it in GitHub Desktop.
Save milnak/e77335e0e1a88664a820966c342eef00 to your computer and use it in GitHub Desktop.
List installed PinHP ROMs, suitable for filtering. #pinhp
<#
.SYNOPSIS
List installed PinHP ROMs, suitable for filtering.
.NOTES
Place this in root of USB.
Prerequisite: advmame106.xml file from "pinHP config files" at https://pinhp.github.io/docs/download.html
Specify location with "-DatFile".
.EXAMPLE
List path of all installed ROMs that require more than 5 buttons:
.\List-PinHP-Roms.ps1 -DatFile '..\pinHP Support\pinHP config files\advmame106.xml' `
| Where-Object Buttons -gt 5 | Select-Object -ExpandProperty FullName
.EXAMPLE
List path and parent of all installed ROMs that are clones:
.\List-PinHP-Roms.ps1 -DatFile '..\pinHP Support\pinHP config files\advmame106.xml' `
| Where-Object CloneOf -ne $null | Select-Object FullName,CloneOf
#>
Param(
[string]$RomFolder = 'rpi2jamma\roms_advmame',
[string]$DatFile = 'advmame106.xml'
)
# Build up hash of rom properties from advmame.xml
$advmame = [xml](Get-Content($DatFile) -ErrorAction Stop)
$hash = @{}
$advmame.mame.game
| Where-Object { $_.runnable -eq 'yes' }
| ForEach-Object {
$hash[$_.name] = [PSCustomObject]@{
Name = $_.name
CloneOf = $_.cloneof
Description = $_.Description
Manufacturer = $_.Manufacturer
Buttons = $_.input.buttons
Control = $_.input.control
Players = $_.input.players
Year = $_.year
}
}
# Iterate rom folder, and list properties for each rom
Get-ChildItem $RomFolder -File -Recurse -Filter '*.zip' | ForEach-Object {
$info = $hash[$_.BaseName]
if ($info) {
[PSCustomObject]@{
FullName = $_.FullName
Name = $info.Name
CloneOf = $info.cloneof
Description = $info.Description
Manufacturer = $info.Manufacturer
Buttons = $info.Buttons
Control = $info.Control
Players = $info.Players
Year = $info.Year
}
}
else {
Write-Warning "Not found: $_"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment