I need to compare file sizes where we're trying to determine if a file output
changed since yesterday. We were thinking of reading the files into variables
and then hashing each of the files to determine if the files are actually the
same. Currently we're only checking for file size differences but a change can
occur without a change to the file size (e.g. one letter change A-->B). CF
documentation says not to read large files into a variable though or it could
bring down the server. Is there a different technique that would help us or a
"plug in" we can obtain that would give us this capability?
BSterner - 29 Aug 2005 23:31 GMT
You can use cfdirectory, and look at the "DATELASTMODIFIED" timestamp.
BSterner - 29 Aug 2005 23:33 GMT
eg)
<cfdirectory action="list" directory="#GetDirectoryFromPath(ExpandPath("*.*"))#" filter="*.txt" name="dir" />
<cfdump var="#dir#" />
a.benton - 30 Aug 2005 15:12 GMT
You should be able to call the code listed below to find the date last modified
of any file.
Ex. <cfoutput>#lastmodified('fullpathtofile')#</cfoutput>
This will return something like {ts '2005-05-31 13:21:40'}
<cfscript>
function lastmodified(filepath) {
var fso=createobject("com", "scripting.filesystemobject");
var thefile=fso.getfile(filepath);
return thefile.datelastmodified;
}
</cfscript>