Skip to content

Instantly share code, notes, and snippets.

@marvolo3d
Last active April 16, 2018 21:32
Show Gist options
  • Save marvolo3d/fed1edbbca680cbc9c1712324f5427e3 to your computer and use it in GitHub Desktop.
Save marvolo3d/fed1edbbca680cbc9c1712324f5427e3 to your computer and use it in GitHub Desktop.
touch all textures in maya scene
import pymel.core as pm
import subprocess
import os
import glob
import re
filesList = []
for fileNode in pm.ls(typ='file'):
filePath = fileNode.fileTextureName.get()
if fileNode.uvTilingMode.get() == 3 and '/pub/' not in filePath: # if using UDIM and not a /pub/ texture
tokenResult = re.search(r"(.*[.])(\d{4})([.].*)", filePath)
splitPath = list(tokenResult.groups())
splitPath[1] = '*'
for x in glob.glob(''.join(splitPath)):
filesList.append(x)
for textureFile in set(filesList):
if not os.path.exists(textureFile):
pm.displayWarning('File {} does not exist'.format(textureFile))
else:
# subprocess.call(['touch', textureFile])
pm.displayInfo('Touched {}'.format(textureFile))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment