Question: I'm new to VBscript and would like some help on moving a specific number of files from one directory to another.

Right now I currently have a set of 3 files(for testing purposes) with different extensions and would like to move all of the files if there are exactly 3 files(no more and no less) inside the source directory. My code so far is:

```
Set fso=CreateObject("Scripting.FileSystemObject")

Set fldr=fso.getFolder("C:\folderA")
for each file in fldr.files
    If fldr.files < 3 then
            msgbox("Need more files")
    Else
            fso.MoveFile "C:\folderA\*", "C:\folderB"
    End If

```

Any help would be greatly appreciated.
Thanks, everyone!

Answer: 
1. Use `fso.getFolder("C:\folderA").Files.Count` to get the number of
files in `C:\folderA`.
2. Do this **before** - not in - a loop over the files (to move them)
3. Consider to move (and re-create) the folder if it contains exactly 3 files
I did the following code and it is working just fine. It is moving for the other 3 different folders looking at the file's name for it and type.

```
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(rootDir)
For each file in f.files
    filename = folderName & file.name

    extFile = right(file.Name, 4) 'gets the file extension .xls

    strExport = left(file.Name,6)  

    strExportAPI = left(file.Name, 3)

    Do

        If (extFile <> ".vbs") Then 

            strsub = "KeyWord"
            index = InStr(file.name, strsub)

        End If  

        If (strExportAPI = "Value") Then 
            fs.CopyFile file, dirKeyWord&file.name
            fs.MoveFile file, dirKeyWord&file.name
            Exit Do             
        End if

        If (index > 0) Then
            fs.CopyFile file, dirKeyWord&file.name
            fs.MoveFile file, dirKeyWord&file.name
            Exit Do
        End If

        Do while (strExport = "export")
            fs.MoveFile file, dirKey3&file.name
            Exit Do 
        Loop            
    Loop While False
Next

```

Tai