Automating Import and Export in Blender

Can someone help me create a script that will import in an OBJ into Blender and then export the same file as an OBJ with only “Material Groups” selected?

Also would it be possible to automate the process by importing the OBJ and then exporting it as an FBX?

I am alright at Python and pretty new to Blender.

Thanks in advance :slight_smile:

edit: I was able to find a solution.