Jump to content
LaunchBox Community Forums

Mame rom cleanup script


Recommended Posts

 

 I wrote a powershell script to cleanup a full (merged) mame romset and remove the following junk:

Non working
Non arcade
No disk dump
CHD Missing
Casino
Mahjong
Playchoice 10
Mechanical
Non Runnabl
Uses Software lists
Clones

 Filtering mame xml is NOT bulletproof.  There are no explicit tags for language or genre so some filtering is tedious and/or may produce undesired results.  So it's best to err on the side of caution.  There will be casino/mahjong games that slip by for example and this even happens with Launchbox mame import.        

 Final tally is that this reduces a mame merged set from 15000+ files to less than 4000 files.

 



function deletefile($file) {

    #Comment next line if you don't want backup
    #$backupfolder = "d:\backupfolder"

    if (($backupfolder -ne $null) -and (($backupfolder | test-path) -eq $false)) {
        md $backupfolder
    }
    
    if ((Get-ChildItem $file -ErrorAction SilentlyContinue) -eq $null) {return}
    
    if ($backupfolder -ne $null) {
        write-host "Moving $file.name to $backupfolder"
        #$file | move-item -Destination $backupfolder
    }
    else {
        write-host "Deleting $file"
        $file | Remove-Item -Force
    }
}



if ($xml -eq $null) {

#Changed to wherever your mame.exe is
[xml]$xml = D:\Launchbox\Emulators\Mame\mame.exe -listxml

}

#Change to wherever your roms are stored
$dir = "Z:\roms\mame"

$xml.mame.machine | ForEach-Object {

    $name = $_.name

    $romfile = $dir + "\" + $name + ".zip"
        
    #Is a bios
    if ($_.isbios -eq "yes") {return}

    #Is a device
    if ($_.isdevice -eq "yes") {return}

    # Delete rom if it has no associated input or coins is null
    if ($_.input -eq $null) {
        deletefile $romfile
        return
    }
    $checkforcoin = $null
    $checkforcoin = ($_ | select -ExpandProperty input).coins
    if ($checkforcoin -eq $null) {
        deletefile $romfile
        return
    }

    #Unplayable
    if ($_.driver.status -eq "preliminary") {deletefile $romfile;return}

    #No disk dump
    if ($_.disk.status -eq "nodump") {deletefile $romfile;return}

    #Missing CHD
    if ($_.disk.status -eq "good") {
        $chdname = $dir + "\" + $_.name + "\" + $_.disk.name + ".chd"
        $checkdir = $null
        $checkdir = Get-ChildItem $chdname -ErrorAction SilentlyContinue
        if ($checkdir -eq $null) {deletefile $romfile;return}
    }
    
    #Not runnbable
    if ($_.runnable -eq "no") {deletefile $romfile;return}

    #Mechanical
    if ($_.ismechanical -eq "yes") {deletefile $romfile;return}

    #Description keywords
    #Playchoice isn't necessary
    #I think most rhythm games are unplayable as well
    if ($_.description -match "playchoice|mahjong|percussion|rhythm|beatmania") {deletefile $romfile;return}
   
    #Slot machine
    if ($_.manufacturer -match "Videos A A|QPS|IGT - International Game Technology|Aristocrat|Igrosoft") {deletefile $romfile;return}
    if ($_.description -match "casino|gamble|slot|fruit|mazooma|gaminator|poker") {deletefile $romfile;return}
    if ($_.sourcefile -match "barcrest|goldstar.cpp") {deletefile $romfile;return}

    #A few junk stragglers
    if ($_.sourcefile -match "nes_clone.cpp|att3b2.cpp|telercas|tvgames|skeleton|aristocrat|casio|yamaha|famibox") {deletefile $romfile;return}
    
    #Uses softwarelist
    if ($_.softwarelist -ne $null) {deletefile $romfile;return}

    #Is a clone.  Not sure we keep or not.  Disabled next line for now
    #if ($_.cloneof -ne $null) {deletefile $romfile;return}

}

 

Edited by Rob_G
  • Like 2
Link to comment
Share on other sites

 

 Ok, one thing I had not counted on was that device roms are not included with the game roms.  So for example, Arkanoid won't launch if mame cannot find m68705p3.zip which is a processor device rom.

 The solution is going to be to not touch device (or bios) zip files now.  I have updated the script to leave these alone.

 Also, I have added a backup option to move files to another location instead of just deleting them if that is what you want.

 I updated the script in the first post.

Rob

 

Edited by Rob_G
  • Like 1
Link to comment
Share on other sites

  • 1 month later...
3 hours ago, DerSchlachter said:

Thank you, i will check the result in my Test-Setup 🤠

 



 

 

 I've changed my approach a bit now. Instead of deleting items, I just hide them by changing the hidden element in the platform or gamelist xml.

 I don't have anything written for launchbox (yet), but I did write something for batocera already..  Same principle though.  This keeps everything in place like bios and device files which are needed, but hides them since they aren't actually games to play.  

 

Rob

Link to comment
Share on other sites

That sounds interesting, if you like you can keep us up to date. I took a closer look at a full import and removed many games such as chess computers, calculators, Mahjong, Casino and games that require a physical device. 400 games have already come together.

Edited by DerSchlachter
Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...