Recursive iteration in folders 2004-08-13 - By Bernard Lebel
Back Hello,
Ok I guess it's pretty simple, but I can't find it. Is there a way to recursively iterate through folders on disk? What I'm trying to do is to point to a root path, then start a loop that will look if the folder contains subfolders, then will look each subfolder to see if they have subfolders, and so on until all folders have been checked and no more folder is found.
I guess a while loop would be perfect for the job, however I have tried several ways of putting it and it stops on the first iteration.
// Get final path to lookup var sPath = \\mypath\blahblahbla;
var fso = new ActiveXObject( "Scripting.FileSystemObject" );
var oFolder, oSubFolders;
// Get folder oFolder = fso.getfolder( sPath );
logmessage( "First oFolder: " + oFolder );
while( oFolder.subfolders.count > 0 ) { oSubFolders = oFolder.subfolders; for( var oSubFoldersEnum = new Enumerator( oSubFolders ); !oSubFoldersEnum.atEnd(); oSubFoldersEnum.moveNext() ) { oFolder = oSubFoldersEnum.item(); logmessage( oFolder ); } }
Thanks Bernard
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|