Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Read txt file and compar with files in folder then copy files compared to folder2 VBS (http://www.go4expert.com/forums/read-txt-file-compar-files-folder-copy-t26953/)

jallloh 17Oct2011 22:11

Read txt file and compar with files in folder then copy files compared to folder2 VBS
 
I'm trying to make my script read a text file which has numbers on each row, then it should compare the text file with some file names that are in a folder, finally its copies the file names it compare with the text file to a another folder.
I'm still learning how to script, so I hope someone out there can help.

Thanks

Code:

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\mytest1\test.txt", ForReading)
Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , ",")
    Wscript.Echo "Server name: " & arrServiceList(0)
    For i = 1 to Ubound(arrServiceList)
        Wscript.Echo "Service: " & arrServiceList(i)
    Next
    Set objFSO = CreateObject("Scripting.FileSystemObject")

If arrServiceList("C:\test1\*.pdf") Then
    objFSO.CopyFile "C:\test1\*.pdf,  "C:\test2\"
Else
    Wscript.Echo "The file does not exist."
End If
Loop



All times are GMT +5.5. The time now is 22:06.