This is what I have so far:
import maya.cmds as cmds
from os import listdir
class Material_library():
def __init__(self):
UI=cmds.window(title="Material Library", widthHeight =(300,150), s=True)
cmds.rowColumnLayout(numberOfColumns = 1)
cmds.button(label= "Select texture folder", command= self.select_folder)
cmds.separator(h=20)
cmds.showWindow()
def select_folder(self, *args):
myFilter= "Image Files (*.jpg *.jpeg *.tga *.png *.tiff *.bmp *.psd)"
self.myDirectory = cmds.fileDialog2(fileFilter=myFilter, dialogStyle=1, fm=3)
myFiles= listdir(self.myDirectory[0])
for textures in myFiles:
fileEndings = ('.psd','.PSD','.jpg','JPG','.jpeg','.JPEG','.tga','.TGA','.png','.PNG','.tiff','.TIFF','.bmp','.BMP')
if textures.endswith(fileEndings):
myTexture = textures
shader=cmds.shadingNode("AiStandardSurface",asShader=True)
else:
cmds.warning(textures + 'This is not a valid image type')
print myFiles
Material_library()