You can do something like this. I just modified the action that selects all vm's for a folder and sub folders. Insert this into an action with a datastoreFolder for an input and an array as an output.
if(!datastoreFolder){
throw "UndefinedParameter: datastoreFolder mandatory input is not defined.";
}
var allDatastores = new Array();
getAllDatastoresInFolder(datastoreFolder);
return allDatastores;
function getAllDatastoresInFolder(folder) {
var children = folder.childEntity;
for (var i in children) {
if (children[i] instanceof VcFolder) {
getAllDatastoresInFolder(children[i]);
}
if (children[i] instanceof VcDatastore) {
allDatastores.push(children[i]);
}
}
}