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.
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.
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.
© 2022 - 2024 — McMap. All rights reserved.