I have a script that periodically downloads information from an RSS feed, one of which is an image. Right now, I am checking if an image exists before loading it using a comparison of FileSystemObject and FileExists so that I do not constantly download the same file again and again. Periodically, the image is updated, but retains the same name, but after running some tests it looks like this: FileExists simply compares the file names, not the actual file. Since the online file and the local file have the same name, it will not load the image, even if they are different images.
My question is, is there any other way to compare files to see if they differ from the name?
This is the function I use:
function saveImageReturnPath(oPath)
dim oFSO
dim oHTTP
dim oStream
dim fol
dim fil
set oFSO = createObject("Scripting.FileSystemObject")
fil = oFSO.getBaseName(oPath) & ".jpg"
if not oFSO.fileExists(localPath & fil) then
set oHTTP = createObject("MSXML2.XMLHTTP")
oHTTP.open "GET", oPath, false
oHTTP.send
set oStream = createObject("ADODB.Stream")
oStream.type = 1
oStream.open
oStream.write oHTTP.responseBody
oStream.saveToFile oFSO.buildPath(localPath, fil), 2
oStream.close
end if
saveImageReturnPath = localPath & fil
end function
Jonny source
share