[Closed] fullfilename + "localtime as string" how to write?
Hi all,
I have a question ,don’t know how to do.
I want to renderout a tga file ,filename add localtime ,Want to some help
Similar this:
rendOutputFilename = fullfilename + “localtime as string” + “.tga”
maxfilepath + maxfilename + localtime + ".tga"
Is what you want but…
localtime = “08/04/2009 15:58:27” so you don’t want / and : in your filename… so…
substring localtime 12 2 + substring localtime 15 2 would give you 1558 instead…
EDIT: and you also need to get rid of the .max on your filename
maxfilepath + substring maxfilename 1 (maxfilename.count - 4) + substring localtime 12 2 + substring localtime 15 2 + ".tga"
Which will output you something like…
“C: est est1619.tga”
“localtime as string” should be (localtime as string). Anything inside ” ” is a string so by putting localtime as string in ” ” it will return “localtime as string”. See the following example blue indicates the returned results to the maxscript listener.
“localtime as string”
“localtime as string”
(localtime as string)
“4/8/2009 10:03:28 AM”
rendOutputFilename = fullfilename + (localtime as string) + “.tga”
-Eric
if you want to be a bit more flexible in the time stamp written out, use getLocalTime(). It’s a bit more work to cast to a string to use, but well worth it.
tStamp = getLocalTime()
#(2009, 4, 3, 8, 17, 39, 52, 77)
tStampStr = stringStream ""
StringStream:""
format "%_%_%@%_%_%" tStamp[1] tStamp[2] tStamp[4] tStamp[5] tStamp[6] tStamp[7] to:tStampStr
OK
tStampStr as string
"2009_4_8@17_39_52"
a dotnet method also from the webulator –
-- overloaded tostring method
-- d: short date
-- D: long date
-- t: short time
-- T: long time
-- f: full Date/Time with short time
-- F: full Date/Time with long time
-- g: general Date/Time with short time
-- G: general Date/Time with long time
-- M or m: month day
-- R or r: RFC1123
-- s: sortable Date/Time that conforms to ISO 8601
-- u: universal sortable Date/Time
-- U: full Date/Time with long time. (This format is the same as F, but it uses universal GMT time.)
-- Y or y: year month
dateTimeInfo = (dotnetclass "system.datetime").Now
dateTimeInfo.ToString "t"
and here’s one using filesystem timestamps
fName = ((sysInfo.tempdir) + (timestamp()) as string)
fHandle = createfile fName
close fHandle
getFileCreateDate fName
what… stop looking at me like that :curious:
I’m looking at you like that because you forgot to delete the file afterwords.
And more of the same, but utilizing a formatted print for a 2 digit hour notation, for better readability when used to output files.
t = getLocalTime()
#(2009, 4, 3, 8, 22, 42, 19, 62)
splitSign = "-"
"-"
renderDate = t[1] as string +"."+ t[2] as string +"."+ t[4] as string + splitSign + (formattedPrint t[5] format:".2d") +"." + (formattedPrint t[6] format:".2d") +"."+ t[7] as string
"2009.4.8-22.42.19"
-Johan
Thanks all ,Problems have been solved,Use ZeBoxx2’s code:
(
try(makedir (pathConfig.convertPathToUnc (maxfilePath + "\ ga\\")))catch()
renderSceneDialog
tStamp = getLocalTime()
tStampStr = stringStream ""
format "%_%_%@%_%_%" tStamp[1] tStamp[2] tStamp[4] tStamp[5] tStamp[6] tStamp[7] to:tStampStr
tStampStr as string
time=tStampStr as string
renderWidth = 2500; renderHeight = 1875
fullfilename = maxFilePath + "\ ga\\" + (getFileNameFile maxfilename)
rendOutputFilename = fullfilename + time + ".tga" ------------------------- File format
rendSaveFile = true
max quick render
)