# Possible to get a list of directories?

**URL:** https://www.finalbuilder.com/forums/t/possible-to-get-a-list-of-directories/744
**Category:** Discussion
**Created:** [February 5, 2008, 10:56am UTC](https://www.finalbuilder.com/forums/t/possible-to-get-a-list-of-directories/744 "2008-02-05T10:56:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mikep](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/m/a4c791/32.png) [@mikep](https://www.finalbuilder.com/forums/u/mikep)
#### Post date: [February 5, 2008, 10:56am UTC](https://www.finalbuilder.com/forums/t/possible-to-get-a-list-of-directories/744/1 "2008-02-05T10:56:29Z")

</div>

Is there any way to get a list of directories under a specified base directory?&nbsp;&nbsp; I want to do this for directories on the same machine FB is running on, not over FTP.&nbsp; I tried the "Find File" action with a wildcard hoping it would return directories, but no such luck.&nbsp; Is it possible?

Thanks,

-Mike

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [February 6, 2008, 12:10pm UTC](https://www.finalbuilder.com/forums/t/possible-to-get-a-list-of-directories/744/2 "2008-02-06T12:10:31Z")

</div>

The scripting filesystemobject ([http://msdn2.microsoft.com/en-us/library/6kxy1a51(VS.85).aspx](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](https://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

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [February 6, 2008, 12:11pm UTC](https://www.finalbuilder.com/forums/t/possible-to-get-a-list-of-directories/744/3 "2008-02-06T12:11:00Z")

</div>

(Sorry, the forum software broke all the indenting.)
