top of page

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

}

}

Recent Posts

See All
Solutions in Nastran

Here's a concise definition table for every solution type (SOL) in NASTRAN, focusing on commonly used ones. Each entry includes the SOL number, solution type, and a brief description. SOL Number Name

 
 
 
Spring elements in NASTRAN

In structural analysis, spring elements play a key role in simulating flexible connections, supports, joints, and contact interactions....

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

© 2023

 
bottom of page