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


[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:

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


+9 # 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] ]
0 # Rion . 2018-12-31 07:16
Quoting Diogo Girondi:
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]]


if i need only /filename_fileprecomp/
what should i do ??

ie : /usr /root/show_name /seq_name/shot_ number/filename _fileprecomp/fi lename_fileprec omp_v098.025.ex r
0 # viktor petrovich 2022-01-08 14:20
Is it possible to make automatic Read node from all images in the parent /images folder?
0 # michael vorberg 2010-08-31 09:38
thank you for comments, i totally forgot that there are other file operations than dirname
+1 # demOOn k 2010-11-27 15:59
if [knob [topnode].file] already contain tcl script - better use [value instead [knob
0 # 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!
0 # 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.

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.
-1 # 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)
0 # 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.
0 # 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"
0 # 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).
0 # 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?
0 # 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
0 # Kristijan M 2018-01-04 13:42
That works PERFECTLY!
Thank you! :)
0 # Frank Rueter 2018-01-04 21:17
oops, yes, I forgot the join bit when I pasted the code.
0 # Andrew Mumford 2019-01-09 20:27
In the hope that this helps someone else this version works directly on the "script" name ... also show how to split in Tcl on more than one character which was the thing that was throwing me - but them I am a total noob...

[join [lrange [split [value root.name] ] end-5 end-1] _ ]
0 # 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
0 # Kumar S 2020-10-19 05:58
how to handle this with append clip node. example if 10 shots connected through append clip. so is it possible render that separate separate from source footage filename ?
+1 # Vladislav Parfentev 2021-06-24 11:43
Thanks guys!
I had a target to take only version from the name of the source. For example, I have source "TEST_0010_v012 .####.exr" and I need to take a version numbers only - "12". I needed it for daylieses

So I've found two ways to do that.

1. If you work with .dpx, .exr, .tiff, .jpeg etc. use this
([join [lrange [split [file dirname [filename [topnode]]] ""] end end]]) + ([join [lrange [split [file dirname [filename [topnode]]] ""] end-1 end-1]])*10

2. If you work with .mov, .mp4 etc. use this
[join [lrange [split [file rootname [filename [topnode]]] ""] end end]] + [join [lrange [split [file rootname [filename [topnode]]] ""] end-1 end-1]]*10
0 # raghavan varada 2023-05-08 06:19
I need input file named exactly on the bottom of shots by using text, when I render qt reference to edit.
this is my command in text node while doing gizmos
[file tail [value [? AutoName==0 filename [topnode].name ]]].
it had shown input1.
But i need the shot name (ex. Shot_001)
Please help me to solve this.
0 # Vladislav Parfentev 2023-05-12 12:01
Give me example of input path and how TCL should convert it (result), please

You have no rights to post comments

We have 2777 guests and 128 members online