Created
April 18, 2019 17:01
-
-
Save izquiratops/8eb63ff400936e67c83a012350175640 to your computer and use it in GitHub Desktop.
Just a script to organize Renderman texture sets into diffuse or normal folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, glob | |
folders = ('./ordered_lib/normal','./ordered_lib/rough-bmp','./ordered_lib/diffuse') | |
for folder in folders: | |
if os.path.isdir(folder) == False: | |
os.makedirs(folder) | |
folders = next(os.walk('./library'))[1] | |
normal_imgs = [] | |
rough_bmp_imgs = [] | |
diffuse_imgs = [] | |
for folder in folders: | |
# Normal maps | |
kind_of_files = ('*_Normal.tif', '*_normal.tif') | |
for kind in kind_of_files: | |
normal_imgs.extend(glob.glob('./library/' + folder + '/' + kind)) | |
# NOT Normal / Diffuse | |
kind_of_files = ('*_Roughness.tif', '*_bmp.tif') | |
for kind in kind_of_files: | |
rough_bmp_imgs.extend(glob.glob('./library/' + folder + '/' + kind)) | |
# Diffuse Only | |
diffuse_imgs.extend(glob.glob('./library/' + folder + '/*.tif')) | |
diffuse_imgs = [item for item in diffuse_imgs if item not in normal_imgs] | |
diffuse_imgs = [item for item in diffuse_imgs if item not in rough_bmp_imgs] | |
normal_imgs = sorted(normal_imgs) | |
rough_bmp_imgs = sorted(rough_bmp_imgs) | |
diffuse_imgs = sorted(diffuse_imgs) | |
for each in diffuse_imgs: | |
namefile = each.rsplit('/',1)[1] | |
# There are diffuse files without normals | |
if os.path.isfile(each[:-4]+'_Normal.tif') or os.path.isfile(each[:-4]+'_normal.tif'): | |
os.rename(each, './ordered_lib/diffuse/' + namefile) | |
else: | |
print(f"No normal map was found for: {each}") | |
for each in normal_imgs: | |
namefile = each.rsplit('/',1)[1] | |
os.rename(each, './ordered_lib/normal/' + namefile) | |
for each in rough_bmp_imgs: | |
namefile = each.rsplit('/',1)[1] | |
os.rename(each, './ordered_lib/rough-bmp/' + namefile) | |
print(f'Done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment