04-08-2018, 06:33 PM
i uploaded my inkopolis model but it was rejected because it had dds textures, how do you convert all 365 of these into png within blender and change the materials' sources as well
@CD /D %~dp0%
@magick mogrify -format png *.dds
@DEL *.dds
@CD /D %~dp0%
@FOR /R %%A IN (*.png) DO PNGOUT "%%A" "%%A" /y
import bpy
# the main looping code snippet is modified from
# https://blender.stackexchange.com/questions/80773/how-to-get-the-name-of-image-of-image-texture-with-python
print('----------------------------------------')
print('Starting the replacer script....')
texture_list = []
count_replaced_files = 0
find_chars = 'dds'
replace_chars = 'png'
for obj in bpy.context.scene.objects:
for s in obj.material_slots:
if s.material and s.material.use_nodes:
for n in s.material.node_tree.nodes:
if n.type == 'TEX_IMAGE':
texture_list += [n.image]
#print(obj.name,'uses',n.image.name,'saved at',n.image.filepath)
if find_chars in n.image.name:
count_replaced_files += 1
old_name = n.image.name
new_name = n.image.name
new_name = new_name.replace(find_chars,replace_chars)
n.image.name = new_name
info_string = old_name + ' has been replaced with ' + new_name
print(info_string)
print(str(count_replaced_files))
print('File were replaced')
print('Finished')
print('----------------------------------------')
#print(texture_list)