/**
 * +----------------------------------------------------------------------------+
 * |                          Jeffrey M. Hunter                                 |
 * |                      jhunter@idevelopment.info                             |
 * |                         www.idevelopment.info                              |
 * |----------------------------------------------------------------------------|
 * |      Copyright (c) 1998-2009 Jeffrey M. Hunter. All rights reserved.       |
 * |----------------------------------------------------------------------------|
 * | FILE       : FileList.js                                                   |
 * | CLASS      : Files and Directories                                         |
 * | PURPOSE    : List all files in a Directory.                                |
 * | PARAMETERS : None                                                          |
 * | USAGE      : cscript FileList.js //NoLogo                                  |
 * | NOTE       : As with any code, ensure to test this script in a development |
 * |              environment before attempting to run it in production.        |
 * +----------------------------------------------------------------------------+
 **/


function main() {

    var objFSO, objFileIterator;
    var strFolder, colFiles, strMessage;

    // Create the FileSystemObject object
    objFSO = new ActiveXObject("Scripting.FileSystemObject");
    
    // Configure FSO to specific folder
    strFolder = objFSO.GetFolder("C:\\temp");
    
    // Get a collection of the files contained in that folder
    colFiles  = strFolder.Files;
    
    // Create an Enumerator in order to iterate through the collection
    objFileIterator = new Enumerator(colFiles);
    
    // Iterate through the Enumeration object and add each file to
    // the temp variable
    strMessage = "";
    for (; !objFileIterator.atEnd(); objFileIterator.moveNext() ) {
        strMessage += objFileIterator.item() + "\n";
    }

    // Print all files in directory
    WScript.Echo(strMessage);

    WScript.Quit(0);
    
}

main();
