Use FileTools:-ListDirectory
dir_name:="C:/tmp"; currentdir(dir_name); #cd to directory files_to_process := FileTools:-ListDirectory(dir_name,'all','returnonly'="*.tex"): numelems(files_to_process) 100
In the above, files_to_process is a list of the files in the current folder with extension
.tex