Based on discussion here:
recursive javascript to list all files/folders in a given folder...[
^]
Following should work:
var WshShell = WScript.CreateObject ("WScript.Shell");
var fs, otf, ForAppending;
ForAppending = 8;
fs = new ActiveXObject("Scripting.FileSystemObject");
otf = fs.OpenTextFile(WshShell.CurrentDirectory+"\\folderList5.txt", ForAppending, true);
var fso
fso = new ActiveXObject("Scripting.FileSystemObject");
createFolderList(WshShell.CurrentDirectory);
otf.Close();
function createFolderList(folderspec)
{
var f = fso.GetFolder(folderspec);
var fc = new Enumerator(f.SubFolders);
for (; !fc.atEnd(); fc.moveNext())
{
otf.WriteLine(fc.item() + "\r\n");
createFolderList(fc.item());
}
}