And the python command (it called from TCL):
[python {nuke.thisNode().metadata()['input/filename'].split('/')[-1]}]
I don't know much about TCL but I could figure it out how it would look like in TCL syntax:
[lindex [split [metadata input/filename] {/}] end]
It reads the node's metadata which is passed through by the current read node. The metadata holds the input/filename key and that is what we are looking for. nuke.thisNode is the node where the comman is called (the Text node in this case). Further information is here. In TCL it seems there is a basic metadata command.