Dim fso, outfile, Graphic, Elem
Dim strFromDir, strToDir, strGraphicList(), i
Set fso = CreateObject("Scripting.FileSystemObject")
Set objEmail = CreateObject("CDO.Message")
' **** Set your Directory Values Here ****
strFromDir = "C:\graphics"
strToDir = "C:\newgraphics"
xmlDir = "c:\testnew\"
i = 0
' **** Looking for the XML file using string RLLO ****
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
Set objFolder = fso.GetFolder(xmlDir)
Set xmlFiles = objFolder.Files
For Each xmlFiles in objFolder.Files
If InStr(xmlFiles,"RLLO") then
xml1Doc = xmlFiles.Name
end If
next
' **** Loading the XML file ****
xmlDoc.load("C:\testnew\" & xml1Doc)
msgbox xml1Doc ' Message to make sure it the correct xml file. Need to remove
Set ElemList = xmlDoc.getElementsByTagName("Ad")
' ElemList.Length will show you how many AD nodes you found
msgbox ElemList.Length ' Message to make sure correct amount of AD's
' Loop Through your Node List
For Each Elem in ElemList
' Check to see if this Node has an Attribute Named Graphic
If not Elem.getAttribute("Graphic") Then
' Make sure the Array is the right Size
Redim Preserve strGraphicList(i)
' If so, assign the attributes value to an Array
strGraphicList(i) = Elem.getAttribute("Graphic")
' Increment the counter
i = i + 1
End If
Next
' Loop Through the Array
For i = 0 to Ubound(strGraphicList)
' Make sure the original File Exists in the Source
If fso.FileExists(strFromDir & "\" & strGraphicList(i)) Then
' Found the File - Copy to Destination
fso.CopyFile strFromDir & "\" & strGraphicList(i), strToDir & "\"
End If
Next
' Message to notify that the files should of copied over
msgbox "All Files should of copied over"
' Validate that All Files exit in Destination
For i = 0 to Ubound(strGraphicList)
' Make sure the original File Exists in the Source
If NOT fso.FileExists(strToDir & "\" & strGraphicList(i)) Then
' File NOT Found
objEmail.From = "[email protected]"
objEmail.To = "[email protected]"
objEmail.Subject = "Graphic " & strGraphicList(i) & " was not found"
objEmail.Textbody = "Graphic ID " & strGraphicList(i) & " was not found"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"xxx.xxx.xxx.xxx"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End If
Next
'Check to see if you have any missing emails send to you
msgbox "Any missing graphic emails?"
'' Deleting the Graphics in the source drive
'For i = 0 to Ubound(strGraphicList)
'' Make sure the original File Exists in the Source
' If fso.FileExists(strFromDir & "\" & strGraphicList(i)) Then
' ' Found the File - Delete file from Source
' fso.DeleteFile strFromDir & "\" & strGraphicList(i)
' End If
'Next
' All graphics in the source drive shoud be deleted
' msgbox "Graphics should be deleted from source"
' Email to be sent to let MAN know Recruit is ready
'objEmail.From = "[email protected]"
'objEmail.To = "[email protected]"
'objEmail.Subject = "Recruit is ready"
'objEmail.Textbody = " Recruit is ready. Have a great weekend"
'objEmail.Configuration.Fields.Item _
' ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'objEmail.Configuration.Fields.Item _
' ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
' "xxx.xxx.xxx.xxx"
'objEmail.Configuration.Fields.Item _
' ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'objEmail.Configuration.Fields.Update
'objEmail.Send
msgbox "Done"
WScript.Quit()
|