VMware Cloud Community
GarTomlon
Enthusiast
Enthusiast
Jump to solution

Create an array of paths from files within a datastore folder

I am looking to create a workflow where a user can select a ISO that is currently in a folder in a datastore.  For instance the Datastore is [MyDatastore] and the folder is isos.  There is iso1.iso, iso2.iso, iso3.iso inside this folder.  How can I pull those filenames/paths  into an array.  I am assuming it will be in a configuration item?  Thanks for your help.

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Check the following sample code showing how to enumerate the files in a datastore folder:

var dsPath = "[MyDatastore] isos";

var task = ds.browser.searchDatastore_Task(dsPath);

var searchResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task, null, 2);

for each (var file in searchResult.file) {

  System.log(file.path);

}

View solution in original post

0 Kudos
1 Reply
iiliev
VMware Employee
VMware Employee
Jump to solution

Check the following sample code showing how to enumerate the files in a datastore folder:

var dsPath = "[MyDatastore] isos";

var task = ds.browser.searchDatastore_Task(dsPath);

var searchResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task, null, 2);

for each (var file in searchResult.file) {

  System.log(file.path);

}

0 Kudos