Tom Wellige 60 Report post Posted September 3, 2019 This post is taken from the Swyx Forum Archive (2007-2014) and was originally posted 12.08.2010 by me The following function fills a VBScript array with the names of a files in a given folder. The names contain the complete path. It can be used for example, to get a list of announcement (.wav) files in a folder to play them one after each other. See example code below... To use the function within your call routing script, just copy&paste it into the "Start" block. '-------------------------------------------------------------- ' GetFilesInFolder() ' ' Reads all file names in given folder into a given array ' ' Parameter: ' Path [in] name of path ' FilesArray [out] array to store all filenames in ' ' Return: ' boolean TRUE - files found ' FALSE - no files found '-------------------------------------------------------------- Function GetFilesInFolder ( Path, ByRef FilesArray ) PBXScript.OutputTrace "-----------> GetFilesInFolder( " & Path & " )" Dim bReturn bReturn = False Dim fso, folder, files, file Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder(Path) Set files = folder.files Redim FilesArray(0) If files.count <> 0 Then bReturn = True For Each file In files Redim Preserve FilesArray(UBound(FilesArray)+1) FilesArray(UBound(FilesArray)) = file.path PBXScript.OutputTrace CStr(UBound(FilesArray)) & ": " & FilesArray(UBound(FilesArray)) Next End If Set fso = Nothing GetFilesInFolder = bReturn PBXScript.OutputTrace "bReturn = " & bReturn PBXScript.OutputTrace "<----------- GetFilesInFolder" End Function The following example code, which could be placed into an "Insert Script Code" block play all .wav files in a given folder: Dim Announcements() Dim i If GetFilesInFolder("C:\Announcements\", Announcements) Then For i = LBound(Announcements) to UBound(Announcements) PlaySound Announcements(i) Next End If 0 Quote Share this post Link to post Share on other sites