EricGoldsteinNz / tadpole

Device Management Tool for the SF2000 / Datafrog retro gaming handheld
Other
94 stars 10 forks source link

Any way to extract every rom file? #72

Open Murderhead opened 3 months ago

Murderhead commented 3 months ago

Would it be possible to add a function to extract every rom file?

Marcinbar commented 1 month ago

I wrote such a script in python. Searches for roms in the "ROMS" directory and the unpacked roms are placed in the "UNPACKED" directory.

import zipfile
import os

onlyfiles = [f for f in os.listdir("./ROMS")]
for f in onlyfiles:
    with open("./ROMS/" + f, 'rb') as in_file:
        with open(f+'.zip', 'wb') as out_file:
            out_file.write(in_file.read()[59904:])
            with zipfile.ZipFile(f+'.zip',"r") as zip_ref:
                if not os.path.exists("./UNPACKED"):
                    os.makedirs("./UNPACKED")
                zip_ref.extractall("./UNPACKED")
    os.remove(f+'.zip')