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!

Not able to print filename from the path

Status
Not open for further replies.

4nn

Programmer
Sep 1, 2010
1
0
0
US
I tried printing only filename from the path using
file tail command, but does not print the filename.

foreach fileName [glob -directory $basedir *.sv] {
puts $fileName
set F [file tail $filename]
puts "FILE $F\e"
}

Result:
/projects/unix/eng/ram/projects/Oxxx/fpga/xxx_fpga/sim/run/TEST/xxx/testcases/testI_EQUALS_1_NOWF_enc_ID.sv
FILE

/projects/unix/eng/ram/projects/Oxxx/fpga/xxx_fpga/sim/run/TEST/xxx/testcases/testI_EQUALS_1_NOWF_huge.sv
FILE
 
You mixed file[highlight]N[/highlight]ame and file[highlight]n[/highlight]ame.
For example this works for me to print all *.txt files in given path:
Code:
set basedir "d:\\work"
foreach filename [glob -directory $basedir *.txt] {
  puts $filename
  set f [file tail $filename]
  puts "file: $f\n"
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top