Adding/Deleting Media files programtically

Is there a way to add or delete media files programmatically using a PHP script?

Welcome to the community, @malembo! Here is a sample of how you can do this by using a Python Script:

Maybe you can make necessary changes as needed for the PHP script.