lstFiles = Files in Directory ("$SAMPLE_DATA\Loss Function Templates");
for each ({i}, lstFiles,
//if extension is .jsl, then it's a script, and should be executed
if (right(i,3)=="jsl", include("$SAMPLE_DATA\Loss Function Templates\"||i));
);
//put values in a new data table
dt = new table ("table",
new column ("Fname", character, set values (lstFiles))
);
This should be what you're looking for. The bit about putting the list in a table doesn't do anything, other than put them in the table, so unless you actually need the filenames in a table, this can be skipped.