Get files in a folder using JScript


I'm trying to write a script to get files in a folder using JScript in Toad Data Modeler. I googled lots, but there are a bunch of incompatible references for JScript.

  var Fs = new ActiveXObject("Scripting.FileSystemObject");
  var Folder = Fs.GetFolder(Path);
  for( i = 1; i < Folder.Files.Count; i++) {
    var file = Folder.Files.Item(i); // This does not work, although it should.
    var file2 = Folder.Files[i]; // This does not work, because it is a collection, not an array.

I need help for:

  1. How to get files in a folder?
  2. Where to get a complete reference for JScript used in Toad Data Modeler?

Kind Regards,

this is working

var FileCollection = Folder.Files;

for(var objEnum = new Enumerator(FileCollection); !objEnum.atEnd(); objEnum.moveNext())
var strFileName = objEnum.item();
Log.Information("File: "+strFileName);

Use JScript or JavaScript to traverse a collection - Visual Studio | Microsoft Learn


Petr, thanks for the answer. I read Microsoft Learn, but it seems like a collection of tutorials and some references. I couldn't find a complete reference. For example, I use MDN for JavaScript and can see every detail about JS there.