max has a rule that after rendering start , the output path can't be edited , so rename was must
by a post render callback , renaming can be automatic
some renderer has its # to frames rule , so use other sign is safe than #
the script below can put to startup path , when render done , result would be auto renamed , by default , it use "@" as sign , not rename in sub path , support max 's main output path and vray's raw and split path , the full path should not use sign besides auto frame area
also apply to rename files already exist , no need edit script , just render an empty image to the path
usage ,set output filename as c:\outputdir\outfilename@@@@@@.png,after rendering , the main output will be c:\outputdir\outfilename@@@@@@1234.png , the script will rename it to c:\outputdir\outfilename001234.png,the default element will be c:\outputdir\outfilename@@@@@@_Object ID1234.png , then c:\outputdir\outfilename_Object ID001234.png , when use vray split , c:\outputdir\outfilename@@@@@@.VRayObjectID.1234.png will be c:\outputdir\outfilename.VRayObjectID.001234.png
fn AEI_ResetFrame =
(
sign = "@"
outputpath=#()
if rendOutputFilename.count > 6 then
append outputpath rendOutputFilename
if isproperty renderers.current #output_splitfilename and renderers.current.output_splitfilename.count > 6 do
append outputpath renderers.current.output_splitfilename
if isproperty renderers.current #output_rawFileName and renderers.current.output_rawFileName.count > 6 do
append outputpath renderers.current.output_rawFileName
for p in outputpath do
for f in getfiles (getFilenamePath p +"\\*" + getFilenameType p) recurse:false do -- if save in split sub path , set recurse to true , 2014 and higher
(
-- main output
fileinfo = (dotNetClass "System.Text.RegularExpressions.Regex").match f ("^(.*?)("+sign+"+)(\d+)(\.[^.]+)$")
if fileinfo.Success then
(
if fileinfo.Groups.item[2].length >= fileinfo.Groups.item[3].length then
(
padding = "000000" + fileinfo.Groups.item[3].value
padding = substring padding (padding.count - fileinfo.Groups.item[2].length + 1) -1
newfile = fileinfo.Groups.item[1].value + padding + fileinfo.Groups.item[4].value
format "Reset result : % - - % --> %\r\n" (renamefile f newfile) f newfile
)else
format "Cancel reset frame from %%%% because of length of % less than existing padding length : %\r\n" sign sign sign sign sign f
)else
(
-- split output
fileinfo = (dotNetClass "System.Text.RegularExpressions.Regex").match f ("^(.*?)("+sign+"+)(.*?)(\.{0,1})(\d+)(\.[^.]+)$")
if fileinfo.Success then
(
if fileinfo.Groups.item[2].length >= fileinfo.Groups.item[5].length then
(
padding = "000000" + fileinfo.Groups.item[5].value
padding = substring padding (padding.count - fileinfo.Groups.item[2].length + 1) -1
newfile = fileinfo.Groups.item[1].value + fileinfo.Groups.item[3].value + fileinfo.Groups.item[4].value + padding + fileinfo.Groups.item[6].value
format "Reset result : % - - % --> %\r\n" (renamefile f newfile) f newfile
)else
format "Cancel reset frame from %%%% because of length of % less than existing padding length : %\r\n" sign sign sign sign sign f
)else
format "Can not reset frame from %%%% : %\r\n" sign sign sign sign f
)
)
print "Reset done"
)
callbacks.removeScripts #postRender id:#AEI_ResetFrame
callbacks.addScript #postRender "AEI_ResetFrame()" id:#AEI_ResetFrame