How to discard and set external material from an Import script?

Godot Version

4.3 stable

Question

I’m having issues with writing a script to get all .glb files from a folder and setting their materials to be discarded and setting their materials to use an external material that I have saved in another folder.

This issue stems from having an asset pack of low poly .glb files that all share the same texture, a color palette. The issue is that while on their own these files are around 300kb, when godot imports them, each extracted texture in the hidden import folder has a size of at least 5mb for some reason.
This creates unnecessary bulk in my project.

So, I thought that writing a script to edit all of the 100+ assets individually would be faster than doing it manually.
The issue is that I don’t know the API to interact with the import settings.
I managed to write a script that set new materials to the meshes, but I didn’t know how to discard the ones already there. My script modifies the meshes, not the import process.

I checked the official documentation to do that, but I didn’t find exactly what I’m looking for, which functions to call or how.

I would appreciate any help at all with this matter.

Is it even possible to do this by script?