Complex scenes linking to textures and models: how to re-link?

I had to replace an old internal SATA hard drive with an SSD. I also thought to assign a different letter to the new hard drive.
The problem is, before the old SATA failed I was working on a fairly complex scene that uses a lot of models and textures linked to external assets.
I recently opened that scene and, of course, all the links to the assets are now broken.
I know how to re-link an asset but the thing is, if I have to do this manually it will take me forever.
Please, tell me there’s a quick way to re-link everything, maybe an add-on…
I use Atomic Data Manager but I don’t think this feature is implemented yet.
Any idea?

So, no solution? only way to do this is manually?

There is menu File / external data/ Find missing files. It works well for textures within a .blend
I’m not sure it handle other type of datablocks .

If the folder structure hasn’t changed, only the drive you can try something like this :

import bpy
for lib in :
    lp = lib.filepath.replace("C:", "D:") # change stuff here
    # uncoment last line once you want to make the change for real
    #lib.filepath = lp

You have to edit the line that starts by lp = , and run it in the text editor.
It will print to the console the corrected path, once it’s good you can uncoment the last line, run the script, save and reload and see if that works.

As this is risky try to backup the files before doing some tests as things can always get worse …

1 Like

That was just great! It worked like a charm!
Thank you so much, @sozap this saved me a painful work :smiley:

1 Like

Great !
Does the find missing files solved everything or you had to use the little script ?

Sorry, I didn’t give much info on that, you’re right.

Well, as I was curious here’s what I did.
I first tried your script and it worked great. Only one asset was still missing (a collection from an external Blend file). Strangely, though, the path for this asset followed the same principle as for all the other assets that your script has been able to relocate (same old path = same new path). But that was really minor, just one asset to relocate.

Then, starting again from the same file with all the missing assets (I kept a couple of copies just in case) I tried with the file/missing files as you suggested. And strangely, again same result: the same collection still missing.

But the good news is, it saved me a lot of work :smiley:

Thank you, @sozap

1 Like

So, an update on this. Lesson learned, I really need to plan my scenes better.
Basically, the solutions you suggested both worked. What I messed up it’s actually something more basic. After I relinked all the missing assets (and most of them were links to collections from external blend files) another issue occurred. Those assets also have materials textures which now, of course, are also missing.

So, I think my solution is either re-link everything from each individual asset scene or make all these linked assets local and then re-link all the missing texture files.