Script error and says no files to process RRS feed

  • Question

  • HI

    I have the folloeng script and it runs as in transferring files from the folders called test to split but then it keeps telling me there no files to process.

    What have I done wrong as there are files in the folder called split.

    Any Ideas?


    HTML Code:
    Option Explicit
    Private Sub SomeSub()
    Dim fso
    ' Global variables
    Dim strBaseDir, strDestDir
    Dim objFSO, objFile
    Dim arrFiles(), i
    Dim lngFolderSize, intFolderNumber, strNextDir, intMoveFile
    ' Define paths to work with
    strBaseDir = "C:\Users\g\Desktop\test"
    strDestDir = "C:\Users\g\Desktop\split"
    strPlayer = "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"
    ' Set maximum size of new folders
    Const cMaxFolderSize = 4294967296#
    ' Define class that will hold file information
    Class File
        Public lngSize
        Public strPath
    End Class
    ' Create file system object
    Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
    ' Fully resolve paths
    strBaseDir = objFSO.GetAbsolutePathname(strBaseDir)
    strDestDir = objFSO.GetAbsolutePathname(strDestDir)
    strPlayer = objFSO.GetAbsolutePathname(strPlayer)
    ' Make sure the folders exists, exit if not
    If Not objFSO.FolderExists(strBaseDir) Then
        WScript.Echo "*ERROR* Folder does not exist: """ & strBaseDir & """."
    End If
    If Not objFSO.FolderExists(strDestDir) Then
        WScript.Echo "*ERROR* Folder does not exist: """ & strDestDir & """."
     End If
    ' Initialize array index variable
    i = -1
    ' Load info for each file into array (using File class)
    For Each objFile In objFSO.GetFolder(strBaseDir).Files
        ' Don't include any files with size greater than max allowed in a folder
        If objFile.Size > cMaxFolderSize Then
            WScript.Echo "*WARNING* Skipping file: """ & objFile.Path & """, size:""" & objFile.Size & """ exceeds maximum folder size:""" & cMaxFolderSize & """."
            ' Add another element to the array of type File class
            i = i + 1
            ReDim Preserve arrFiles(i)
            Set arrFiles(i) = New File
            ' Store the size and full path to the file
            arrFiles(i).strPath = objFile.Path
            arrFiles(i).lngSize = objFile.Size
        End If
    ' If no files found then exit
    If i = -1 Then
        WScript.Echo "*WARNING* No files found to process."
    End If
    ' Sort the files arrary by size in descending order
    SortArray arrFiles
    ' Process all files moving to new subfolders until done
    intFolderNumber = 0
        ' Start a new destination folder and create it (MUST NOT ALREADY EXIST)
        lngFolderSize = cMaxFolderSize
        intFolderNumber = intFolderNumber + 1
        strNextDir = strDestDir & "\" & intFolderNumber & "\"
        objFSO.CreateFolder strNextDir
        ' Move files to dest folder until full
            ' Look for the largest file left that will fit in remaining space
            intMoveFile = GetFileToMove(arrFiles, lngFolderSize)
            ' If we found another file to move then move it
            If intMoveFile <> -1 Then
    Dest:          [" & intFolderNumber & "] , Available: [" & lngFolderSize & "] , File: [" & arrFiles(intMoveFile).strPath & "] , Size: [" & arrFiles(intMoveFile).lngSize & "]
                objFSO.MoveFile arrFiles(intMoveFile).strPath, strNextDir
                lngFolderSize = lngFolderSize - arrFiles(intMoveFile).lngSize
                arrFiles(intMoveFile).lngSize = -1
            End If
        Loop Until intMoveFile = -1
        ' Add player file
        objFSO.CopyFile strPlayer, strNextDir
    Loop Until AllFilesMoved(arrFiles)
    End Sub
    Function GetFileToMove(ByRef arrArray(), lngSize)
        ' Find next largest file to move that fits, -1 if none found
        Dim i
        GetFileToMove = -1
        For i = LBound(arrArray) To UBound(arrArray)
            If arrArray(i).lngSize <> -1 Then
                If arrArray(i).lngSize <= lngSize Then
                    GetFileToMove = i
                End If
                Exit Function
            End If
    End Function
    Function AllFilesMoved(ByRef arrArray())
        ' See if all files have been moved
        Dim i
        AllFilesMoved = True
        For i = LBound(arrArray) To UBound(arrArray)
            If arrArray(i).lngSize <> -1 Then
                AllFilesMoved = False
                Exit Function
            End If
    End Function
    Sub SortArray(ByRef arrArray())
        ' Sort array of files by size, descending order (simple bubble sort)
        Dim i, j, intTemp
        For i = LBound(arrArray) To UBound(arrArray)
            For j = LBound(arrArray) To UBound(arrArray) - 1
    '            If arrArray(j).lngSize < arrArray(j + 1).lngSize Then
                If LCase(arrArray(j).strPath) > LCase(arrArray(j + 1).strPath) Then
                    Set intTemp = arrArray(j + 1)
                    Set arrArray(j + 1) = arrArray(j)
                    Set arrArray(j) = intTemp
                    Set intTemp = Nothing
                End If
    End Sub
    • Moved by Alex-KSGZ Wednesday, November 21, 2018 7:48 AM
    Wednesday, November 14, 2018 8:41 PM

All replies

  • Not to state the ovious but this does not look like VB.NET, if you can confirm this then this is the wrong forum and I can move your question to the vbs forum which is as good as it gets or leave here and hope someone has something to offer but as stated this forum is for vb.net language.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, November 14, 2018 8:46 PM
  • sorry yeah it a vb script and not a vb.net 
    Thursday, November 15, 2018 6:28 PM
  • Hi,

    This forum is discussing and asking questions about the vb.net, it will be more appropriate to ask your question at Microsoft Community.


    Thank you for your understanding.

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 16, 2018 12:59 AM