Found the solution to the date handling problem in the Query of Query
against a CFDIRECTORY result. Just use a CFQUERYPARAM in the CFQUERY below,
as in:

<cfquery DBTYPE="query" NAME="getonlyfiles">
        select * from getfiles
        where datelastmodified <= <cfqueryparam
value="#indate#" cfsqltype="CF_SQL_DATE">
</cfquery>

/charlie


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of charles arehart
> Sent: Saturday, June 22, 2002 2:47 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFTALKTor] Delete directory
>
>
> You could use a CFDIRECTORY ACTION="list" NAME="queryname", which
> creates a
> query result set holding all the info about the files and directories you
> point it to. One of those is the modified date, available in one of the
> "query columns" it creates, called queryname.dateLastModified.
>
> Next, you could (in CF5 or CFMX) use a query of queries to select
> only those
> in that original result set that met your condition. Just be
> aware that the
> query of queries features does NOT support ODBC datetime formats, so be
> careful when doing your comparisons. The example below demonstrates a few
> features.
>
> For those who don't have either CF5 or CFMX, you could also just do an IF
> test on this column in a CFLOOP or CFOUTPUT over the query.
>
> Finally, if you find that you don't have access to the CFDIRECTORY command
> because the admin has disabled it for security reasons, check out my Feb
> 2002 article, "Unlocking Restricted Use of CFFILE, CFCONTENT, and More"
> available online at my site,
> www.systemanage.com/cff/articles.cfm. It shows
> some solutions for resolving that problem (and explains why it
> may be setup
> that way).
>
> Oh, and as for how to delete them, that's CFDIRECTORY Action-"delete" for
> directories, and CFFILE action="delete" for Files. To determine
> which you're
> looking at while looping through them, test for type="File". (Note, too,
> that if you happen to put that Type="file" into the SQL, the query of
> queries feature is case-sensitive as to the values on the right
> side of the
> = in a Where clause.)
>
> /charlie
>
> PS Here's a code sample.
>
> This looks at the files and dirs in the current directory where
> the template
> is located (see the DIRECTORY attribute value). Then it sets a
> date (just to
> show how you might have it be driven by a variable, perhaps an input form
> variable).
>
> I even go a step further and query that result set yet again to
> get a total
> of the files (and/or dirs) found that meet that date criterion. I've also
> found that for this to work in CFMX , you need to change the sum(size) to
> sum ([size]) because Size is a reserved word in CFMX's Q of Q.
> See that doc,
> above.
>
> In the end, I CFDUMP the result of the CFDIR query resultset, to help
> visualize what it is I'm subsetting in case I need to do any debugging of
> the SQL being built.
>
> A bigger problem, that I could not resolve tonight, is that I'm
> finding that
> the attempt to use the date for comparison in CFMX is failing. It compares
> but finds 0 records. In my case, I do have files that were created before
> that date (according to the CFDUMP), so it seems it doesn't like a
> comparison between the datelastmodified field and the date (or any date) I
> tried, regardless of how it was formatted. If anyone solves that,
> please let
> me know.
>
>
> <CFDIRECTORY ACTION="LIST" DIRECTORY="#expandpath(".")#" NAME="getfiles">
>
> <cfset indate = "05-01-02">
>
> <cfquery DBTYPE="query" NAME="getonlyfiles">
>       select * from getfiles
>       where datelastmodified <= '#indate#'
> </cfquery>
>
> <cfquery DBTYPE="query" NAME="gettotal">
>       select sum(size) as total from getonlyfiles
> </cfquery>
>
> <h4>Directory Total Size in Bytes:
> <cfoutput>#numberformat(gettotal.total)#</cfoutput>
> </h4>
>
> <p>
>
> <cfdump VAR="#getfiles#">
>
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> > Behalf Of Eric Corser
> > Sent: Friday, June 21, 2002 1:35 PM
> > To: [EMAIL PROTECTED]
> > Subject: [CFTALKTor] Delete directory
> >
> >
> > Does anyone know a way to walk through a directory and delete all
> > directories/files older than a certain date?  Any help is appreciated.
> > Thanks.
> >
> > -
> > You are subscribed to the CFUGToronto CFTALK ListSRV.
> > This message has been posted by: "Eric Corser" <[EMAIL PROTECTED]>
> > To Unsubscribe, Please Visit and Login to http://www.CFUGToronto.org/
> > Manager: Kevin Towes ([EMAIL PROTECTED])
> > http://www.CFUGToronto.org/
> > This System has been donated by Infopreneur, Inc.
> > (http://www.infopreneur.net)
> >
>
> -
> You are subscribed to the CFUGToronto CFTALK ListSRV.
> This message has been posted by: "charles arehart"
> <[EMAIL PROTECTED]>
> To Unsubscribe, Please Visit and Login to http://www.CFUGToronto.org/
> Manager: Kevin Towes ([EMAIL PROTECTED])
http://www.CFUGToronto.org/
This System has been donated by Infopreneur, Inc.
(http://www.infopreneur.net)

-
You are subscribed to the CFUGToronto CFTALK ListSRV.
This message has been posted by: "charles arehart" <[EMAIL PROTECTED]>
To Unsubscribe, Please Visit and Login to http://www.CFUGToronto.org/
Manager: Kevin Towes ([EMAIL PROTECTED]) http://www.CFUGToronto.org/
This System has been donated by Infopreneur, Inc.
(http://www.infopreneur.net)

Reply via email to