Build Your Own Arcade Controls Forum

Main => Software Forum => Topic started by: tony.silveira on April 17, 2020, 04:17:48 pm

Title: easy way to remove roms if not in xml?
Post by: tony.silveira on April 17, 2020, 04:17:48 pm
hi guys,

i have a 209 set, 12k+ games listed and i have a curated xml that only has 3k games (only, sheesh).

the front end i am using is listing all games in my rom folder.  so, is there anyway to compare roms in the folder to an xml file and move missing roms or just delete them outright?

thanks
Title: Re: easy way to remove roms if not in xml?
Post by: MacGyver on May 12, 2020, 09:03:12 am
Easy, not that I know of. no.

So I usually make a Powershell script to do that kind of thing.
But you should never have the script do anything, you should have it make a batchfile to do it, that way you can review it line by line before it applies anything to your files.

Code: [Select]
$inputfile = "./mame209.xml"
$outputfile = "./move-roms.bat"

if (Test-Path $outputfile){Remove-Item $outputfile}

$masterlist_list = New-Object System.Collections.ArrayList
foreach($list in Get-Content $inputfile)
{
$masterlist_list.Add($list) > $null
}
foreach($line in $masterlist_list)
{
if($line -like '*game name*'){
$lines = $line -split('\"')
$moveline = 'move ' + $lines[1] + '.zip d:\new-folder\'
write-host $moveline
Add-Content $outputfile $moveline
}
}
Read-Host -Prompt “Press Enter to exit”

The above .ps1 file will open your file (here named mame209.xml) and match every line of it against "*game name*" (this is at the beginning before each rom), and then it splits that matching line into pieces at the " symbol, it then takes the second piece after the " and adds the move commands around it (target here is the d:\new-folder\), then creates a .bat file with all the commands.
Review the newly created "move-roms.bat" and fix it as needed.
When run it moves the ones you want, and leaves the ones not in the list, but keep them around (see below).

It's pretty straightforward, just modify it as you need, or post your .xml (or a piece of it) and I can help you out.

Know that if you have your roms split, you will have to manually add the missing parents if your list has clones.
You can also script that, but I'd need to see the XML.