Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove file path and extension in Tcl command

Tags:

tcl

say the file path is saved as an variable f

puts "$f"

Then outcome is

/home/usr/testfile.txt

I want to remove everything but the name, 'testfile' and save it in a new variable.

like image 615
Bryan Avatar asked Dec 05 '22 20:12

Bryan


1 Answers

The file command is what you want.

 set fbasename [file rootname [file tail $f]]

file tail is the last component of the filename. file rootname is everything excepting the extension.

like image 79
Brad Lanam Avatar answered Dec 16 '22 06:12

Brad Lanam