You can do it by creating a MEL script but i am guessing this might be a little advanced for you.
here is a link that shows how to go about it
https://www.scriptswell.net/2010/12/m...-write-to.html
You should check out the "ls" flag which is a list command, your string would be something like
string $allObjects[];
$allObjects = `ls`;
i am by no means an expert with MEL and perhaps some of the more competent users on here will help more.
2 x Modeling Challenge Winner