Is there any simple way to get all missing .blend libraries, in a python list, set, tuple or dictionary?

The operator bpy.ops.file.report_missing_files() only prints this list in the console. If I put it in a variable, the only thing I have is a set: {'FINISHED'} !! To illustrate:

missing_libs = bpy.ops.file.report_missing_files()
# missing libraries are printed in the console at this point, one line a file
# prints {'FINISHED'} in the console

Ideally, I want to be able to do, for example:

nb_missing_libs = len(missing_libs) # get the number of missing libraries
for mlib in missing_libs:
    if ".blend" in mlib:
        # Do something with mlib

Is there a fast and easy way ?


You could try a variation of the following code:

import bpy
import os

def list_missing_blend_libs():
    return [bpy.path.abspath(lib.filepath) for lib in bpy.data.libraries
            if not os.path.exists(bpy.path.abspath(lib.filepath))]

Using bpy.path.abspath, it only lists absolute path of missing libraries in bpy.data.libraries.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.