Hi Scot. Sorry for not making it clearer. The code people have supplied
hasn't been working code, it's been for you to use as an idea to get your's
to work.

The cfdump is not needed, it was just a quick way to see the result of the
DateCompare().

Forget about deleting the file to begin with, instead just output to screen
the files that would be deleted.


<cfdirectory action="list" directory="#application.logpath#"
name="dir_listing">

<!--- Filter out directories --->
<cfquery name="dir_listing" dbtype="query">
        SELECT * FROM dir_listing WHERE Type = 'File'
</cfquery>

<cfloop query="dir_listing">

        <cfset objDateLastModified = 
parsedatetime(dir_listing.DateLastModified)>

        <cfif DateCompare(DateAdd("d", -60, Now()), objDateLastModified) GTE 0>
                <p><cfoutput>#dir_listing.Name#(#DateFormat(objDateLastModified,
"dd/mm/yyyy")#) will be deleted</cfoutput></p>
                <!--- <cffile action="delete"
file="#application.logpath#/#dir_listing.Name#"> --->
        </cfif>

</cfloop>

If it looks like is has the right files then uncomment the cffile.

If it doesn't work then play about with this line...

<cfif DateCompare(DateAdd("d", -60, Now()), objDateLastModified) GTE 0>

.... till it does.

Ade

-----Original Message-----
From: Scot VanAlstine [mailto:[EMAIL PROTECTED]
Sent: 29 March 2005 19:12
To: CF-Newbie
Subject: Re: converting file dates read with cf directory

Well I removed the quotes from around the dateLastModified variable.

<CFSET logPath = "#application.logPath#">
<CFDIRECTORY ACTION="List" DIRECTORY="#logPath#" NAME="dir_listing">
<cfloop query="dir_listing">
<cfset dateString = dateLastModified>
<cfset dateObj = ParseDateTime(dateString)>
<cfdump var="#DateCompare(dateObj, Now())#">
<cfif DateCompare(dateObj, Now()) GTE 0>
<cffile action="DELETE" file="#logPath#/#name#">
</cfif>
</cfloop>


I run the previous code and get a series of "-1"s on the the screen.
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

I look in the directory and everything is still there.

Here are the last modified dates on the files in the directory:

10/30/2001
5/17/2002
5/17/2002
5/24/2002
9/13/2002
9/13/2002
1/9/2003
1/10/2003
6/12/2003
7/30/2003
8/5/2003
8/18/2003
9/3/2003
10/5/2004
3/7/2005

Any ideas anyone?
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.4 - Release Date: 27/03/2005


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:15:799
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to