Reputation: 339
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
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