Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract filename from full path name 1

Status
Not open for further replies.

BTCMan

Programmer
Jun 17, 2005
21
0
0
BR
Hi people,

can somebody tells me how can I extract the file name from a variable full path (path + filename)?
Sample:

set fullpathinfo "/aaa/.../bbb/ccc/filename1.txt"
set filenameresult ""
[unknow code here to extract only filename1.txt and put it into variable filenameresult]
[...]
puts $filenameresult
% filename1

Basically I need some rule that searches untill the last "/" in the input "fullpathinfo" variable and then extract the remaining string. (we cannot rely on a fixed pathname - they can vary)

Can anybody help me please? Thanks
 
never mind I discovered using "file tail"

Sample:
set pathdir "/xxx/yyy/sdfgfdh/zexinhoDSG.xml"
set ze [file tail $pathdir]
puts $ze

<out put is just the filename zexinhoDSG.xml>

Thiago
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top