On 06/03/2014 at 11:02, xxxxxxxx wrote:
here is a script i use for this. it has some limitations - if you need it often renomi is defently the bedder choise in case of other languarges and comp tools
import c4d
from c4d import gui
import commands
import os
import shutil
from glob import glob
### postwendend.com ###
### tobias hoffmann ###
### [email protected] ###
def listdir(d) :
return [os.path.join(d,fn) for fn in next(os.walk(d))[2]]
def main() :
rd = doc.GetActiveRenderData()
rd_long = doc.GetActiveRenderData()
vp = rd.GetFirstMultipass()
single_path = rd[c4d.RDATA_PATH]
multi_path = rd[c4d.RDATA_MULTIPASS_FILENAME]
multi_path_global = multi_path
multi_path_arr = []
multi_path_arr = multi_path.split("\")
i = 0
arr_len = len (multi_path_arr)
arr_len = arr_len - 1
multi_path = ""
while i < arr_len:
multi_path = multi_path + multi_path_arr[i] + "\"
i = i + 1
object_buffer_arr = []
object_bufferID_arr = []
pfadarr = []
file_type_arr = []
file_name = multi_path_arr[arr_len]
i = 0
j = 0
k = 0
while vp:
if vp.GetTypeName() == "Object Buffer":
object_buffer_arr.append (vp.GetName())
object_bufferID_arr.append (vp[c4d.MULTIPASSOBJECT_OBJECTBUFFER])
j = j + 1
mp_name = vp.GetName()
multipass_type = ""
if mp_name == "RGBA Image":
multipass_type = "rgb"
elif mp_name == "Ambient":
multipass_type = "ambient"
elif mp_name == "Ambient Occlusion":
multipass_type = "ao"
elif mp_name == "Atmosphere":
multipass_type = "atmos"
elif mp_name == "Atmosphere (Multiply)":
multipass_type = "atmosmul"
elif mp_name == "Caustics":
multipass_type = "caustics"
elif mp_name == "Depth":
multipass_type = "depth"
elif mp_name == "Diffuse":
multipass_type = "diffuse"
elif mp_name == "Global Illumination":
multipass_type = "gi"
elif mp_name == "Illumination":
multipass_type = "illum"
elif mp_name == "Material Color":
multipass_type = "matcolor"
elif mp_name == "Material Diffusion":
multipass_type = "matdif"
elif mp_name == "Material Environment":
multipass_type = "matenv"
elif mp_name == "Material Luminance":
multipass_type = "matlum"
elif mp_name == "Material Reflection":
multipass_type = "matrefl"
elif mp_name == "Material Refraction":
multipass_type = "matrefr"
elif mp_name == "Material Specular":
multipass_type = "matspec"
elif mp_name == "Material Specular Color":
multipass_type = "matspeccol"
elif mp_name == "Material Transparency":
multipass_type = "mattrans"
elif mp_name == "Motion Vector":
multipass_type = "motion"
elif mp_name == "Material Normal":
multipass_type = "normal"
elif mp_name == "Specular":
multipass_type = "specular"
elif mp_name == "Shadow":
multipass_type = "shadow"
elif mp_name == "Material UVW":
multipass_type = "uv"
elif mp_name == "Reflection":
multipass_type = "refl"
elif mp_name == "Refraction":
multipass_type = "refr"
elif mp_name == "Post Effects":
multipass_type = "post"
path_temp = (multi_path)
file_type_arr.append (multipass_type)
path_temp = os.path.normpath(path_temp)
pfadarr.append (path_temp)
vp = vp.GetNext()
for item in pfadarr:
pos1 = pfadarr[i] + "\" + file_name + "_" + file_type_arr [i]+"*"
pos1 = os.path.normpath(pos1)
pos2 = pfadarr[i] + "\" + file_type_arr [i] + "\"
pos2 = os.path.normpath(pos2)
pos3 = pfadarr[i] + "\" + file_type_arr [i] + "\"
pos3 = os.path.normpath(pos3)
os.system ("mkdir " + pos3)
os.system ("move " + pos1 + " " + pos2)
i = i + 1
renderoutput = []
renderoutput = listdir(multi_path)
renderoutput_len = len ( renderoutput )
i = 0
while i < renderoutput_len:
renderoutput_filename= renderoutput[i].replace(multi_path, "")
while k < j:
str_helper = "object_" + str(object_bufferID_arr[k])
if renderoutput[i].find ( str_helper ) > 0:
if object_buffer_arr[k] == "Object Buffer":
renderoutput_filename = renderoutput_filename.replace(str_helper, object_buffer_arr[k] + "_" + str(object_bufferID_arr[k]))
if os.path.isdir ( multi_path + "Object_Buffer" + str(object_bufferID_arr[k])) == 0:
os.system ("mkdir " + multi_path + "Object_Buffer_" + str(object_bufferID_arr[k]))
os.rename ( renderoutput[i], multi_path + "Object_Buffer_" + str(object_bufferID_arr[k]) + "\" + renderoutput_filename )
else:
renderoutput_filename = renderoutput_filename.replace("_object" , "_" + object_buffer_arr[k] )
if os.path.isdir ( multi_path + object_buffer_arr[k]) == 0:
os.system ("mkdir " + multi_path + object_buffer_arr[k])
os.system ("move " + renderoutput[i] + " " + multi_path + object_buffer_arr[k] + "\" + renderoutput_filename)
k = k + 1
k = 0
i = i + 1
if __name__=='__main__':
main()