I am a newbie to VBScript and need help with this code. Here is a script which is for copying files. My requirement is to copy file names starting with "ml_*" (asterick to act as wildcard) in folder (X:\ABC) and all other files in folder (X:\PQR). For some reason it is not working. Any help is appreciated.
strComputer = "."
Set objNetwork = CreateObject("Wscript.Network")
Set fs = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='U:\'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFiles
if objFile.FileName = "ml_*" Then
destinationPROD = "X:\ABC\" & objFile.FileName & "." & objFile.Extension
objFile.Copy(destinationPROD)
objFile.delete
else
destinationPROD = "X:\PQR\" & objFile.FileName & "." & objFile.Extension
objFile.Copy(destinationPROD)
objFile.delete
End If
Next
strComputer = "."
Set objNetwork = CreateObject("Wscript.Network")
Set fs = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='U:\'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFiles
if objFile.FileName = "ml_*" Then
destinationPROD = "X:\ABC\" & objFile.FileName & "." & objFile.Extension
objFile.Copy(destinationPROD)
objFile.delete
else
destinationPROD = "X:\PQR\" & objFile.FileName & "." & objFile.Extension
objFile.Copy(destinationPROD)
objFile.delete
End If
Next