Loading Clips names from a folder

mabulazm

Member
Hi All,
i'm reading clips names from text file but i thought it'd be more efficient if I can read all clips names from the folder itself and then push them to a ComoBox.
Is there any way to read names of all files exist in a folder instead of reading it from txt file.

this is what i'm using now
Code:
sub loadClipsFile()
       clipNameControl.Items.loadFromFile "\\LOOPS.txt"
       clipNameControl.Sorted = True
end sub

cheers,
Mo
 
Hi All,
i'm reading clips names from text file but i thought it'd be more efficient if I can read all clips names from the folder itself and then push them to a ComoBox.
Is there any way to read names of all files exist in a folder instead of reading it from txt file.

this is what i'm using now
Code:
sub loadClipsFile()
clipNameControl.Items.loadFromFile "\\LOOPS.txt"
clipNameControl.Sorted = True
end sub

cheers,
Mo


Try this script, maybe it will help you:

Code:
Sub InitForm
    Call ListFiles("lboFiles", "e:\VizShareVideo\", "avi")
    Call ListFiles("cboFiles", "\\localhost\VizShareVideo\", "avi")
End Sub

Function ListFiles(component, mediaFolder, ext)
    If IsObject(FindComponent(component)) Then
       FindComponent(component).Clear
    Else
       Exit Function
    End If
    Set objFSO = CreateObject("Scripting.FileSystemObject")
       If objFSO.FolderExists(mediaFolder) Then
          Set objFolder = objFSO.GetFolder(mediaFolder)
          Set colFiles = objFolder.Files
          For Each objFile in colFiles
              If LCase(objFSO.GetExtensionName(objFile.Name)) = ext Then
                  FindComponent(component).Items.Add objFile.Name
              End If
         Next
    End If
    Set objFSO = Nothing
End Function

J.

ListFiles.jpg
 

Attachments

  • ListFiles.jpg
    ListFiles.jpg
    143.7 KB · Views: 39
thanks so much, works perfectly.
Do you think we can add the name without the file extension ?


e.g.

Code:
Function ListFiles(component, mediaFolder, ext)
    If IsObject(FindComponent(component)) Then
       FindComponent(component).Clear
    Else
       Exit Function
    End If
    Set objFSO = CreateObject("Scripting.FileSystemObject")
       If objFSO.FolderExists(mediaFolder) Then
          Set objFolder = objFSO.GetFolder(mediaFolder)
          Set colFiles = objFolder.Files
          For Each objFile in colFiles
              If LCase(objFSO.GetExtensionName(objFile.Name)) = ext Then
                  FindComponent(component).Items.Add Replace(objFile.Name, "." & ext, "")
              End If
         Next
    End If
    Set objFSO = Nothing
End Function
 
Back
Top