<cfquery name="StoryInfo" datasource="nNews">
where id > 680000
directory="C:\serverroot\n<wbr ></wbr><wbr ></wbr>server\ine<wbr ></wbr>ws"
<cfquery name="mydirectory" dbtype="query">
where size < 2048
<cffile action = "delete" file="C:\serverroot\nserve<wbr ></wbr><wbr ></wbr>r\inews\#m<wbr ></wbr>ydirectory<wbr ></wbr>.name#">
News thumbnails are automatically generated from a news feed using cffile. Once in a while an image is created that's corrupted. It's always less than about 2k in size. I've wasted too much time attempting to discover the reason and now only wish to delete those images on a schedule using ColdFusion.
I want to use CF administrator's Sheduled Event to run this code to delete all files less than the given size.
But with hundreds of thousands of files in the same directory, this takes far too long. How can I look at only the last 100 or so images in the directory so the process goes much faster? I mean, why look at all the files in the folder when all I want are the last 100 or so created? And they are all in numerical order.
I included a cfquery just in case we can use it to shorten the time. Use my snippet as the example. Show me what needs to be changed to make it work.