Oh I see. Well there are a couple ways to do this.
If you want to use the nuke.tcl() method, you'll need to evaluate each TCL expression separately. So the two Python calls would look like this:
Code:
nuke.tcl("string trimleft [lindex [split [string trim [file tail [value root.name]] .nk] _] 1] v")
nuke.tcl("string trim [file tail [value root.name]] .nk")
Note that the top-level (outer-most) square brackets have been removed. This is because the TCL interpreter evaluates each nested set of brackets from the inside out, so if they were left in there, your expression would be evaluated and the return value would be passed to nuke.tcl(), which would then try and run that string in the TCL interpreter again, causing the "Unknown command" error.
However, there's an easier solution to all of this: Just call the Write node's File knob's ".evaluate()" method to return the fully-substituted path. Then you can use something like os.path to test for existing levels of the tree and create them if necessary.
Code:
path = <WriteNode>['file'].evaluate()
Hope this helps.