Hey Moogy,
I started out using file -q -l for this sort of thing, and I agree it's a real pain in the rear. Luckily, there's also the -r flag which lists only references. So all you need to do is:
string $allRefs[] = file -q -r
;
for ($ref in $allRefs) {
file -ir $ref;
}
There is one additional thing to watch out for - what if there are unloaded references in the scene. Trying to import them will cause an error. If you are concerned about this you can insert the following inside the main for loop, before the file -ir statement.
if (file -q -dr $ref
) {
file -lr $ref;
// load it first
}
Hope this is helpful!
-Harry