diula
Oct. 22, 2006 10:19:51
Hello,
Is it possible (in Houdini, Windows) to somehow extract the current time and date? I would like to append the resulting string to the name of my many test render frames…
It appears that of all the variables defined on the system, one cannot extract only the Date and Time
Any ideas?
rdms
Oct. 22, 2006 17:14:37
diula
Hello,
Is it possible (in Houdini, Windows) to somehow extract the current time and date? I would like to append the resulting string to the name of my many test render frames…
It appears that of all the variables defined on the system, one cannot extract only the Date and Time
Any ideas?
You could use system expression and do something like:
set a = `system(“date +%T”)` —> 18:08:16
or
set a = `system(“date +%D”)` —-> 10/22/06
or
set a = `system(“date +%D_%T”)` —-> 10/22/06_18:08:16
Hope this helps a bit
edward
Oct. 22, 2006 18:56:07
On Windows, I think you need to install cygwin or gnuwin32 in order to use the Unix date utility.
Le_monkey_butt
Oct. 23, 2006 04:46:20
On Windows, you can do it more or less like in Linux without having to install Cygwin
set time = `arg(system(date),3)`;
for the date you need to get it this way:
set dayOfWeek = `arg(system(date),0)`;
set date = `arg(system(date),1)`;
set month = `arg(system(date),2)`;
Maybe a better way though….
DriesD
Nov. 2, 2006 08:18:55
Did anyone get this working?
On windows, the system command doesnt' seem to work.
/ -> set time = `system(date /T)`
/ -> echo $time
/ ->
DriesD
Nov. 2, 2006 08:21:39
Edit: duplicate
Le_monkey_butt
Nov. 2, 2006 08:30:40
set time = `arg(system(date),3)`;
echo $time
works
and if it doesnt work with the “date” from windows, it is because I have UnxUtils
http://sourceforge.net/projects/unxutils/ [
sourceforge.net]
a bunch of UNIX utils very easy to install:
- Download
- Put the folder where ever you want
- Make sure that the environment var PATH has the directory where UnxUtils is installed….
puma.snyder
Nov. 3, 2006 10:38:20
It works without any UNIX tools. Basicly date is a cmd application, so you need to call it something like this (I forgot the exact syntax and no Houdini near me):
system(cmd(date))
or
system(cmd date)
Achim
DriesD
Nov. 6, 2006 09:29:22
Good tip, thanks.
turned out I had to use this structure in textport :
echo `system(“cmd /c date /t”)`
ben5ch
April 19, 2007 13:10:59
Just been playing with this problem as well. Here follows a little trick you can do get the current system time on Windows.
The $ExportNode can be any node but I used the ROP node I was executing the script from in which I needed systemtime.
opset -h off $ExportNode
opset -h on $ExportNode
set FullTime = `execute(“opstat -m $ExportNode”)`
set ExportTime = `arg($FullTime,5)`
cheers,
benS
TangheStudent
Jan. 13, 2022 13:33:49
I spend some time trying diferent system commands in the name but every timei try this the sting gets split somehow and i end up with an unnumbered 0 kb file where the name ends after the system command.
examples $HIP/render/projection/%HIPNAME_`system("powershell Get-Date -Format 'MM_dd_HH:mm'").4F.exr
yieds a folder with 1_13_12:44 no extention or anything.
are we sure $DATE isnt a thing ?
netlander
Sept. 6, 2023 15:24:23
TangheStudent
examples $HIP/render/projection/%HIPNAME_`system("powershell Get-Date -Format 'MM_dd_HH:mm'").4F.exr
yieds a folder with 1_13_12:44 no extention or anything.
This works well on Windows except that the colon character cannot be used as a folder or file name on a Windows system.
tamte
Sept. 7, 2023 01:27:42
This thread is since before there was a Python in Houdini
But nowadays you can probably just use Python and be consistent across OSs
Jonathan de Blok
Sept. 7, 2023 04:17:56
I jumped on the houdini bandwagon around version 15, surprised to learn it was without python once!
Mike_A
Oct. 28, 2024 12:27:03
18 years after the original post - and I still can't work out how to add current date and time to my ROP filename output.
on Windows.
If some generous person could write me a 'copy and paste' line to add date and time to the standard ROP file name string of:
$HIP/render/$HIPNAME.$OS.$F4.exr
I'd really appreciate it.
toadstorm
Oct. 28, 2024 18:10:29
This can be done as a one-liner but it requires some pretty esoteric Python formatting because it needs to import the datetime module before running datetime.now().strftime(). Try something like this:
$HIP/render/$HIPNAME.$OS.`pythonexprs("str(__import__('datetime').datetime.now().strftime('%Y%m%d_%H%M%S'))")`.$F4.exr
Running __import__ this way and converting the whole thing to a string allows you to import, run the function, and return the result as a string for pythonexprs to read all at once. It's ugly but it works. If you want something a little easier to modify, you could create a string-type spare parm and set the default expression to this Python statement:
import datetime
return datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
Then just include a reference to that channel in your output path, like this:
$HIP/render/$HIPNAME.$OS.`chs("myTimeChannel")`.$F4.exr
Mike_A
Oct. 29, 2024 19:29:38
Henry,
Please excuse the tardiness of this reply - but thank you so much for this excellent and useful post. I will be putting it to use later this week. I've used a date and time token frequently in other 3D software, and very much missed it in Houdini - but no longer : )
Most appreciated.
eikonoklastes
Oct. 30, 2024 03:29:43
Mike_A
18 years after the original post - and I still can't work out how to add current date and time to my ROP filename output.
What's the use case for appending the date and time to the file name that isn't covered by the embedded date and time in the file already?
Mike_A
Oct. 30, 2024 17:06:12
You can easily repeat render without accidently overwriting files for a start.
It was something I set up and used a lot in C4D for file organisation.