# How to check if a texture is already in the blend file before importing it while appending an object?

Matthew here with yet another question :p

Anyway...I found an answer by @zeffi on how to append an object using python, that's all goods, but the trouble is, every time I append that object, it imports the textures in, every time, which means that after about 5 appends, I have 5 copies of every single texture, which slows blender down dramatically, and also increases my file size from 150mb to something like 1gb...sooo, here is what I was thinking, in steps:

Append the object, then check if all the textures imported in with the last 'append' are there already, and if they are, then delete them, otherwise leave them there. It sounds pretty simple but I just don't know how to go about it. Here is the part of code that should concern so far:

class AddMacBook(bpy.types.Operator):

def execute(self, context):

macbook_path = '/Users/MacBook/Documents/Blender/Blends/MacBook/Macbook.blend'

macbook = 'Macbook'
screen = 'Screen'
Directory = macbook_path + "/Object/"
m_path = Directory + macbook
s_path = Directory + screen

wm = bpy.ops.wm
wm.append(filepath=m_path, filename=macbook, directory=Directory)
wm.append(filepath=s_path, filename=screen, directory=Directory)

• This should obviously be an builtin append feature. I guess the way that 3d studio max does it is best. It checks for materials that has the same name, If the names are the same, a dialogue box will pop up asking you if you would like to keep the material and rename it, or use the one already available in the blend file. – hawkenfox Jan 8 '16 at 7:34
• Do you know how I could achieve the same effect? – mr-matt Jan 8 '16 at 7:55
• – zeffii Jan 8 '16 at 12:21
• lol, the first link is this exact question! And the second one, does it not import textures? – mr-matt Jan 8 '16 at 18:58