<commit_before>import os
import re
import sys
import glob
import datetime
from maya import cmds, mel

def editShaderValue():
    # 
    # Input your target attribute.
    # 
    attributes = [
        'diffuse',
        'colorR',
    ]
    
    anisotropicList = cmds.ls(typ='anisotropic') or []
    for asl in anisotropicList:
        print '[ %s ]' % asl
        for attr in attributes:
            if cmds.attributeQuery(attr, n=asl, ex=True):
                cmds.setAttr('%s.%s' % (asl, attr), .0)
                print '\t%s >>> .0' % attr

def getLatestFile(dirPath='F:/', fileFilter='', fileExt='.mb'):
    if not os.path.isdir(dirPath):
        return ''
    dirPath = dirPath.replace(os.sep, '/')
    searchPath = '%s%s*%s' % (dirPath, fileFilter, fileExt)
    files = glob.glob(searchPath)
    if not files:
        return []
    latestFile = max(files, key=os.path.getctime)
    latestFile = latestFile.replace(os.sep, '/')
    return latestFile

# 
# Input your root folder.
# 
rootPath = r'F:\aaa\bbb\ccc'

# Get target folder.
elements = glob.glob('%s/*' % rootPath)

# 
# If you have subfolders, edit here.
# 
subFolderPath = r'hoge\scenes'

# Get the date of today.
today = datetime.datetime.today().strftime('%Y%m%d%H%M%S')

for element in elements:
    targetFolderPath = '/'.join([element, subFolderPath])
    targetFolderPath = '%s/' % targetFolderPath

    # Get the latest file.
    latestFile = getLatestFile(
        dirPath=targetFolderPath,
        fileFilter='',
        fileExt='.mb'
    )
    
    # File open.
    cmds.file(
        latestFile,
        f=True,
        o=True
    )

    # Edit the material.
    editShaderValue()
    
    # File save.
    basename = os.path.basename(latestFile)
    temps = basename.split('.')
    extension = temps[-1]
    fileName = basename.replace('.%s' % extension, '')
    newName = '_'.join([fileName, 'editMaterial%s' % today])
    newFilePath = '%s%s.%s' % (targetFolderPath, newName, extension)
    
    cmds.file(rename=newFilePath)
    cmds.file(save=True, type="mayaBinary")<commit_msg>Update shineSongRiceField.py<commit_after>import os
import re
import sys
import glob
import datetime
from maya import cmds, mel

def editShaderValue():
    # 
    # Input your target attribute.
    # 
    attributes = [
        'diffuse',
        'colorR',
    ]
    
    anisotropicList = cmds.ls(typ='anisotropic') or []
    for asl in anisotropicList:
        print '[ %s ]' % asl
        for attr in attributes:
            if cmds.attributeQuery(attr, n=asl, ex=True):
                cmds.setAttr('%s.%s' % (asl, attr), .0)
                print '\t%s >>> .0' % attr

def getLatestFile(dirPath='F:/', fileFilter='', fileExt='.mb'):
    if not os.path.isdir(dirPath):
        return ''
    dirPath = dirPath.replace(os.sep, '/')
    searchPath = '%s%s*%s' % (dirPath, fileFilter, fileExt)
    files = glob.glob(searchPath)
    if not files:
        return []
    latestFile = max(files, key=os.path.getctime)
    latestFile = latestFile.replace(os.sep, '/')
    return latestFile

# 
# Input your root folder.
# 
rootPath = r'F:\aaa\bbb\ccc'

# Get target folder.
elements = glob.glob('%s/*' % rootPath)

# 
# If you have subfolders, edit here.
# 
subFolderPath = r'hoge\scenes'

# Get the date of today.
today = datetime.datetime.today().strftime('%Y%m%d%H%M%S')

for element in elements:
    targetFolderPath = '/'.join([element, subFolderPath])
    targetFolderPath = '%s/' % targetFolderPath

    # Get the latest file.
    latestFile = getLatestFile(
        dirPath=targetFolderPath,
        fileFilter='',
        fileExt='.mb'
    )
    
    # File open.
    cmds.file(
        latestFile,
        f=True,
        o=True
    )

    # Edit the material.
    editShaderValue()
    
    # File save.
    basename = os.path.basename(latestFile)
    temps = basename.split('.')
    extension = temps[-1]
    fileName = basename.replace('.%s' % extension, '')
    if re.search('editAMat', fileName):
        fileName = fileName.split('_editAMat')[0]
    newName = '_'.join([fileName, 'editAMat%s' % today])
    newFilePath = '%s%s.%s' % (targetFolderPath, newName, extension)
    
    cmds.file(rename=newFilePath)
    cmds.file(save=True, type="mayaBinary")
{'fraction_non_alphanumeric': 0.14471506266256798, 'fraction_numerical': 0.001655237644833294, 'mean_word_length': 2.5877862595419847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4131259', 'n_tokens_mistral': 1467, 'n_tokens_neox': 1440, 'n_words': 319}