Dim fso, outfile, Graphic, Elem
Dim strFromDir, strToDir, strGraphicList(), i
Set fso = CreateObject("Scripting.FileSystemObject")
' **** Set your Directory Values Here ****
strFromDir = "C:\Original"
strToDir = "C:\New"
i = 0
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load("C:\test\test.XML")
Set ElemList = xmlDoc.getElementsByTagName("Ad")
' ElemList.Length will show you how many AD nodes you found
' msgbox ElemList.Length
' 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) - 1
' Make sure the original File Exists in the Source
If fso.FileExists(sstrFromDir & "\" & strGraphicList(i)) Then
' Found the File - Copy to Destination
fso.CopyFile strFromDir & "\" & strGraphicList(i), strToDir & "\"
End If
Next
' Validate that All Files exit in Destination
For i = 0 to Ubound(strGraphicList) - 1
' Make sure the original File Exists in the Source
If NOT fso.FileExists(strToDir & "\" & strGraphicList(i)) Then
' Found NOT Found
msgbox "Graphic ID " & strGraphicList(i) & "was not found"
End If
Next
msgbox "Done"
|