Splitting many objects

I have an imported mesh containing several unlinked objects and I want to separate them into unique objects. The problem is that it is so tedious to manually go through all the objects and separate them using ‘P’. I guess it should be possible to do a script that does this but I haven’t found one. Does anyone here know if this has been addressed before?

Select all in edit mode (A).
Press P and choose “all loose parts” from the popup.
This way all unlinked meshes will become extra objects.

Pat