AryT
AryT

Reputation: 43

Run all TCL scripts in a folder

I have a folder with many TCL files, and I need to run them all (in Vivado). How can I save time in running all of them at once? Is there something as easy as: source [path/]*.tcl ?

Upvotes: 4

Views: 4314

Answers (3)

Mostafa Wael
Mostafa Wael

Reputation: 3846

To run all the scripts in a given directory and its sub-directories you may use the tcllib as follows:

package require fileutil
foreach script [fileutil::findByPattern $baseDir *.tcl] {
    source $script
}

Upvotes: 0

TM90
TM90

Reputation: 700

You could first just find all tcl files with the glob command and then go though the list of tcl files and source them.

set $dir your/path
foreach file [glob -dir $dir */*.tcl] {
    source $file
}

Edit: In difference to Peters example this solution also sources .tcl files in subdirectories (Be sure you want this).

Upvotes: 2

Peter Lewerin
Peter Lewerin

Reputation: 13282

How about

foreach script [glob -nocomplain -dir $dir *.tcl] {source $script}

?

Documentation: foreach, glob, source

Upvotes: 8

Related Questions