Replacing one material with another (2.8)

If you want to replace several object’s material with another, you usually press shift-L /ctrl-L to assign the selected material
but when these objects have more than one material each and you just want to change the one material they have in common what do you do?

to explain: I have imported a building from sketchup and because it was too big, I imported it in two parts: floor 1 and floor 2. Now the problem is that each floor (which consist of several objects) has a separate material for wall but I want to apply just one. the thing is that some objects have on them more than one materials. I tried using shift-L/ ctrl-L but it doesn’t work

You can try clean_cad_mats.

you don’t get me,
that’s not the point. the point is to be able to replace a material for many objects at once if they have more than one materials…
e.g. if you have 10 objects, that each has a porcelain and a chrome material and you want to replace the chrome material for those objects with -lets say- aluminium, what would you do?
currently I have to select them one by one and do the replacement.

just wondering here !

do all material have the same name and different numbers at the end ?

happy bl

no, they don’t

if same name then you could simply go to the material menu and change the material and all objects will use it

happy bl

Couldn’t you just copy and paste all the nodes from one material to the other?

are you guys serious???

you mean to tell me there is no simple way to replace one material throughout the scene with another?
oh, the humanity!!!
It is things like this that make me thing that blender will never be a professional application

Using python api

import bpy
old_mat ="The name of material to replace")
new_mat ="The name of the new material")

You may also find this useful…

I’m not sure I understand correctly but I think you’re showing copying the shaders from one material to another right?
If that’s correct, then you have the problem that if you make changes to one material, the other one will not be updated with these changes…

If that’s what you want, you can use the second method displayed.

  1. Select an object with the material you wish to change
  2. Press “Shift+L” to open the “Select Linked” menu
  3. Select the “Materials” options in order to select all objects with that same material
  4. “Shift+Click” one object that already has the new material you want to apply to selected objects
  5. Press “Ctrl+L” to open the “Make Links” menu and select the “Materials” option

Since they are now linked, if you change the material for one object, the rest will update also.

come on man…
you went through the trouble of making a gif but not to read the questsion:

I’ve said it three times already, I know this procedure. What I’m asking is if one object has two or more materials and you want to change just one of them, this method does not give you control over which material you can change. It only works for single material objects!

did this using the addon I mentioned to you before

Looks like what you want


I don’t think the feature you want is implemented yet. In the outliner you can select multiple materials, You would then want to right click and select ‘make single user’ - You could then just choose your custom material to replace all the existing materials.You can ‘right click’ and ‘remap user’ but its still painful to have to change each slot one at a time…

The function is there but it doesn’t do anything, I would guess it’s going to be a feature soon enough.

Hi Stephen, i know your post i almost a year old, but your three lines of code might be just what i need :slight_smile:
I there a way to exchange all the materials in a scene at once using your approach?

My case is as follows- I use a different Software for nurbs modelling, and import into Blender via FBX format-
In my Nurbs Software i have a Material library that I use all the time- and when exporting as fbx, blender keeps the proper name of each material- just the actual Materials are useless…
My Hope is to rebuild my material library on the blenderside using the exact names, and then save it as a Library(maybe linking a Blend file?)- so when ever I import an fbx, with materials with the same name blender should replace all the shaders with the ones from that Blendfile. Do you think its possible with scripting?
Greetings James

Something like this should work to replace materials by name from library

import bpy
library_path = "path to library file.blend"

# get mat names available in library
with as (data_from, data_to):
        available = set(data_from.materials)

old_mats = { mat for mat in if in available}

# assign temp name to old materials
for name, mat in old_mats.items(): = "{}_tmp".format(name)

# load from library
with, False, False) as (data_from, data_to):
    data_to.materials = list(old_mats.keys())

# replace or remove temp name
for name, mat in old_mats.items():
    new_mat =
    if new_mat is None: = name


HI Stephen, Thanks for you script and great explanation in it :slight_smile:
I will try to test it- if I get it to work… (not sure how to tell python the path yet, but i will try to figure it out)
My original idea was to have the materials already linked into the working file by using Link/append, so
I wouldn´t have to define a path to the File… would that also be feasible?