List the files in the folder by using TCL
- Admin
- Nov 27
- 1 min read
Here is a simple script to list all the files in a folder with or without file extension.
set folder [tk_chooseDirectory -title "Select a folder"]
if {$folder eq ""} {
puts "No folder selected."
return
}
# Get file list
set files [glob -nocomplain -directory $folder *]
# FILES WITH EXTENSION
foreach f $files {
if {[file isfile $f]} {
puts [file tail $f]
}
}
# FILES WITHOUT EXTENSION
foreach f $files {
if {[file isfile $f]} {
set name [file rootname [file tail $f]]
puts $name
}
}

Comments