Radiant: How to use the TCL command "prj_add_source" to include a list of files on Radiant project based on file type via scripting flow?

Radiant: How to use the TCL command "prj_add_source" to include a list of files on Radiant project based on file type via scripting flow?

Here is an example TCL script on how to automate adding of files, based on file type, to a Radiant project via scripting flow:

#set the directory to a variable where you want to get the files. 
set dir /home/jmangubat/ 

#use glob command to filter the files based on the file type. In this example, *.vhd file type is filtered. 
set file_list [glob -directory $dir *.vhd] 

#use foreach to list the filtered files and add them to the project one by one. 

foreach file $file_list 
 prj_add_source -impl impl1 $file 
}