Bryan
Bryan

Reputation: 339

remove file path and extension in Tcl command

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.

Upvotes: 5

Views: 19384

Answers (1)

Brad Lanam
Brad Lanam

Reputation: 5763

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.

Upvotes: 20

Related Questions