03 tcl提取文件路径操作
1 设置和拆分文件路径
(1) 设置文件路径名
格式:
file join dirlist
dirlist : 路径元素列表,以空格隔开;
返回值:返回dirlist 元素以(== ‘/’==)间隔开的路径名;
范例:
% set path [file join tcl program filename.tcl]
tcl/program/filename.tcl
% puts $path
tcl/program/filename.tcl
(2) 拆分文件路径名,生成路径元素列表
格式:
file split dirname
dirname:路径名,可包含文件名
以==’/’==作为标志,拆分路径,生成路径元素列表;
返回值:返回dirlist
范例:
% puts $path
tcl/program/filename.tcl
% file split $path
tcl program filename.tcl