write nodes filename from topmost read

Written by michael vorberg on .

if you need your output file named exactly like your input file then use a little TCL expression in the file knob of the write node

suggestion your filename convention is like: //path/to/file/filename.pattern.ext

then:

1
[lindex [split [lindex [split [knob [topnode].file] .] 0] /] end]

 

will give you back just the "filename" part of the original read node

if you want to write to same folder as the original file but with a new filename extension you could use:

1
[file dirname [knob [topnode].file]]/[lindex [split [lindex [split [knob [topnode].file] .] 0] /] end]_conv.%04d.exr

Comments   

 
+8 # Diogo Girondi 2010-08-30 08:41
You could also just use

Root dir:
[file dirname [knob [topnode].file] ]

File name:
[file tail [knob [topnode].file] ]

File extension:
[file extension [knob [topnode].file] ]
 
 
# michael vorberg 2010-08-31 09:38
thank you for comments, i totally forgot that there are other file operations than dirname
 
 
# demOOn k 2010-11-27 15:59
if [knob [topnode].file] already contain tcl script - better use [value instead [knob
 
 
# Leonardo Yabiku Terukina 2010-12-29 01:06
but..., what happens if you have the read node merged with a constant (in B, or A, whathever...). It gives me:
Nothing is named ''node##nn##### .file''.
Any suggenstions?

Thank you!
 
 
# Leonardo Yabiku Terukina 2010-12-29 18:26
Excuse me, what happens if I have the read node merged with a constant (constant in B)?
 
 
+1 # viktor petrovich 2011-03-03 11:06
if you have merge operation - script try to take source filename from B node (in your case is not file with name) so that is why an error
i noticed that issue and flip sources (shift+x)

but here i have an suggestion:
- could anyone correct this recipe to take filename not from previous Read node but from first one (Read1)

PS - how to make this script write with SAME filename but in new folder which was manually created in folder where is Read1 node file is
 
 
+1 # mayur pati 2014-11-17 13:15
hi When iam rendering quicktime mov with tif seq renders, its taking full name and frame number too. i want avoid frame number while rendering mov.

ex:
my tif seq is : "zebra_V01_C002 _b01_101.tiff"
"_101" is my frame numbers
i want it to be render as "zebra_V01_C002 _b01.mov"
 
 
+1 # Alex Doss 2016-03-14 13:10
[file rootname [knob [topnode].file] ]_mask.tif
_mask.tif is just a string to concatenate I needed to use.

rootname returns the full path up to the filnename, excluding the extension.
Handy..
 
 
# Michael Clemens 2017-12-06 19:27
how would this expression change if your Write Node was in a GROUP?

Can you have it still look for the top most node in the stream (outside of the group)
 
 
# Alex Doss 2018-01-04 13:42
Something along the lines of:
[file rootname [knob [topnode this.parent.inp ut].file] ]_mask.tif

sorry for the late reply.
 
 
# Kristijan M 2018-01-03 14:48
This is cool but it still keeps frame number.
How would you go about this so it takes out
frame number and extension?
so keep path, keep name only add .mov in the end.
Thanks a bunch"
 
 
# Frank Rueter 2018-01-03 21:17
It depends on what your naming is. Are your frame numbers delimited by a dot or an underscore? E.g. If your frame number is delimited by a dot you can use something like this:

[lrange [split [file rootname [filename [topnode]]] "."] 0 end-1].mov

this drops the extension, splits the result into a list using dots as delimiters, then reassembles that list with dots again, dropping the last item (which presumably is your frame number).
 
 
# Kristijan M 2018-01-04 11:50
Hi, yes, thanks. Obviously in my case its the underscore :D
When using dots as separators it's easier but I always get name_v01_####.e xt frames anyway to go around this?
 
 
# Alex Doss 2018-01-04 13:35
Not sure how Frank's code will join the string after the split.
This line will split "." OR "_"
Because I dropped the file rootname part, it returns the fullname of the file including extension, this is why lrange is set to (0, -2).
Finally joining everything using "_"

[join [lrange [split [knob [topnode].file] ".|_"] 0 end-2] "_"].mov

Glad it worked Kristijan, your welcome :D
 
 
# Kristijan M 2018-01-04 13:42
That works PERFECTLY!
Thank you! :)
 
 
# Frank Rueter 2018-01-04 21:17
oops, yes, I forgot the join bit when I pasted the code.
 
 
# ryan peticca 2018-07-20 19:47
I am trying to apply this script and it works. but I have my reads into a switch at the top of the pipe. and it only names based on frame 0. how could you make it take each read nodes name based on the switch.


something like this, but the constants are .exr's


Constant {
inputs 0
channels rgb
color {1 0 0.063009 0}
color_panelDropped true
name kingAurther
selected true
xpos 3920
ypos -1329
}
Constant {
inputs 0
channels rgb
color {1 0.427098 0 0}
color_panelDropped true
name sirRobin
selected true
xpos 3810
ypos -1329
}
Constant {
inputs 0
channels rgb
color {0.052967 1 0 0}
color_panelDropped true
name greenKnight
selected true
xpos 3700
ypos -1329
}
Constant {
inputs 0
channels rgb
color {0.845645 0 1 0}
color_panelDropped true
name lancelot
selected true
xpos 3590
ypos -1329
}
Constant {
inputs 0
channels rgb
color {0 0 1 0}
color_panelDropped true
name sirBedivere
selected true
xpos 3480
ypos -1329
}
Switch {
inputs 5
which {{"\[frame]"}}
name Switch5
selected true
xpos 3711
ypos -923
}
Write {
file "C:/Users/KP-PC 01/Desktop/New folder/\[file tail \[knob \[topnode].file]].jpeg"
file_type jpeg
checkHashOnRead false
name Write3
selected true
xpos 3711
ypos -835
}
 

You have no rights to post comments

We have 1983 guests and 110 members online