Skip to main content
1 of 4
bill s
  • 69.7k
  • 4
  • 103
  • 198

One way to go about this is read in the file names - this way you don't have to explicitly check to see if they exist.

 path = SystemDialogInput["Directory", NotebookDirectory[]];
 fileNames = FileNames["*.txt", path];
 allFiles = Table[Import[fileNames[[num]]], {num, 1, Length[fileNames]}];

Of course you could use Get instead of Import.

bill s
  • 69.7k
  • 4
  • 103
  • 198