Is there any way to get a list of directories under a specified base directory? I want to do this for directories on the same machine FB is running on, not over FTP. I tried the "Find File" action with a wildcard hoping it would return directories, but no such luck. Is it possible? Thanks, -Mike
The scripting filesystemobject (http://msdn2.microsoft.com/en-us/library/6kxy1a51(VS.85).aspx) may be the only way to do this.
In JScript, it would look something like this:
alert(“Immediate subfolders: " + ListSubfolders(“C:\Temp”).length);
alert(“All subfolders : " + ListSubfoldersRecursive(“C:\Temp”).length);
var asTextList = ListSubfolders(“C:\Temp”).join(”\r\n”); // One path per line
function ListSubfolders(folderPath) // Returns an array with the paths of subfolders to ‘folderPath’
{
var fso = new ActiveXObject(“Scripting.FileSystemObject”);
var folder = fso.GetFolder(folderPath);
if(folder == null)
throw "Folder not found : " + folderPath;
var enumfolders = new Enumerator(folder.SubFolders);
var paths = new Array;
for(enumfolders.moveFirst(); !enumfolders.atEnd(); enumfolders.moveNext())
{
paths.push(enumfolders.item().Path);
}
return paths;
}
function ListSubfoldersRecursive(folderPath) // Returns an array with paths of all subfolders beneath ‘folderPath’
{
//Action.SendLogMessage("Listing " + folderPath);
var children = ListSubfolders(folderPath)
var childLength = children.length;
for(var j = 0; j < childLength; j++)
children = children.concat(ListSubfoldersRecursive(children[j]));
return children;
}
Please let us know if there’s anything further we can help you with.
Regards,
Angus
(Sorry, the forum software broke all the indenting.)