import os

# Define the directory containing .UAKM files
directory = "."

# Iterate through all files in the directory
for filename in os.listdir(directory):
    if filename.lower().endswith(".uakm"):
        filepath = os.path.join(directory, filename)
        
        with open(filepath, "rb") as file:
            data = file.read()
            pal_data = data[:0x300]
            dbe_data = data[0x300:]

        base_name = os.path.splitext(filename)[0]
        pal_filename = os.path.join(directory, base_name + ".pal")
        dbe_filename = os.path.join(directory, base_name + ".dbe")

        with open(pal_filename, "wb") as pal_file:
            pal_file.write(pal_data)

        with open(dbe_filename, "wb") as dbe_file:
            dbe_file.write(dbe_data)

print("All .UAKM files have been split into .pal and .dbe files.")

