PDA

View Full Version : Creating new folder and reducing strings


Monotoner
11-20-2007, 11:44 PM
Hi,

I'm trying to create a script to batch send out max files to network render. All my files are named with "_00" ( eg. "3456_00.max" "12_01.max" ) .

I need to output the targa sequence to individual folders named after the max files(eg. "3456_00.max" will render to "c:/3456/3456_.tga)

Is there anyway to


1) remove the last 3 characters of a string? i tried using substring but the total number of characters in different for each max file name.

2) create a new folder to a specific directory with a given name using maxscript?

Thanks in advance for any replies

oglop
11-21-2007, 07:13 AM
edit: sure , i've added more comments

u r facing the same problem as i did last week, i was asked to create a submission script to submit files and texture maps to Muster network render.

1) yes of course u can use substring to do it



-- get current scene name base
mySceneName = getFileNameFile maxFileName

imageNameBase = substring mySceneName 1 (mySceneName.count-3)




2) yes u can do that, but i used an ugly way to do it. I try to output different render element to seperate folders, and intentionally add an extra "." to the image name.

my image output path is like \\file-server\..\sceneName\renderElementName\sceneName_renderElementName..tga

then my image will appear as
sceneName_renderElementName.####.tga

and stored in separate folders, this way it's more clean and tidy

i'm using the following function to create folder


-- make sure network path share exists
-- before i set any image output path, i'll use this function to ensure path exists
fn hjEnsurePathExist dir=
(
print ("working on dir : "+ dir)
-- filter path with / or \ , if my path is \\server\image\outputPath\, i'll get --ar("server","image","outputPath")
ar = filterString dir "\\/"
if (dir[1]=="\\") then
(
-- because 1st token is server name, 2nd token is share folder name, so we don't --need to check these two folder exists or not
local basePath = "\\\\" + ar[1] + "\\" + ar[2]+ "\\"
local currentDir = basePath
-- we check from the 3rd token
for i = 3 to (ar.count) do
(
currentDir += ar[i]+"\\"
-- doesFileExist also works on folders, we check if it exists or not
if (not doesFileExist currentDir) then
(
-- if folder not exist, we creat it, substring is used to remove last \, makeDir --need path name ends without \
makeDir (substring currentDir 1 (currentDir.count-1))
print ("making dir "+ currentDir)
)

)
)
)




and u can use GetCurRenderElementMgr to access render element (set path, naming convention etc.), global var rendSaveFile , rendoutputfilename to set output image name

Monotoner
11-21-2007, 02:46 PM
Hi,

Can you please help me explain ur code line by line? It seems great to use it for organising rendering file in layers or elements. I would really like to know how it works. Thanks :)

TheIvIaxx
11-21-2007, 07:20 PM
getFilenameFile maxFileName

CGTalk Moderation
11-21-2007, 07:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.