I have a logfile with a date at the begining of each record.  
The record ends with a carriage return.
I want to read the dates and delete from the file all records that are over 30 
calendar days old.
I have gotten stalled and need help. Any assistance will be appreciated.


Here is an example of my log file:

09/30/2004 08:43:34 AM ale      -- File: blah.txt upload complete.
09/30/2004 08:43:46 AM ale      -- rm -rf '/train9/upload'
09/30/2004 08:43:48 AM ale      -- File: upload delete complete.
10/07/2004 10:37:49 AM ale      -- mkdir -m 775 '/train9/blah'
10/07/2004 10:37:51 AM ale      -- Successfully made directory '/train9/blah'.
10/07/2004 10:39:32 AM ale      -- Send File 'U:\projects
10/07/2004 10:39:38 AM ale      -- File: cfdir_err.doc upload 


I am comparing dates but am getting an Invalid CFML construct found on the 
following line at column 58:

24 :  <cfif (DateDiff("d",now(),"DateFormat(Content_array[1],"mm-dd-yyyy"") GTE 
31)>


Here is an example of all my documented code so far:

<cffile action="Read" file="http://www.wirez.com/testserver/TRAIN09.log"; 
variable="str_Content">
<cfset bln_FirstLine = true>

<!--- default var --->

<cfset New_File = "">

<!--- Loop through the lines--->

<cfloop
  list="#str_Content#"
  delimiters="#chr(13)##chr(10)#"
  index="str_Line">
  <!--- Set line as an array--->
  <cfset Content_array = #ListtoArray(str_Line)#>

  <!--- Need to do something with the date - may need to set the date as -7 or 
something like that might want to use DateDiff()
  DateDiff("y: Day of year ", "DateFormat(Content_array[1],"mm-dd-yyyy")", 
"#DateFormat(Now()")
  DateFormat(Content_array[1],"mm-dd-yyyy")  GT #DateFormat(Now() - 7, 
"mm-dd-yyyy"--->

 <cfif (DateDiff("d",now(),"DateFormat(Content_array[1],"mm-dd-yyyy"") GTE 31)>

        <!---  if the line is a keeper, drop it into a new var - may have to 
play with the set commmand, you want to append the line to the existing var, 
may need to use & signs for the set 
         New_File & ArraytoList(Content_array) & chr(13) & chr(10) - or 
something like that --->

        <cfset New_File = 
"#New_File##ArraytoList(Content_array)##chr(13)##chr(10)#">
  </cfif>
</cfloop>

<!--- Write the file back - destination  D:/vars/wirez... --->
<!--- <cfset comparison = DateCompare(FORM.date1, FORM.date2, 
FORM.precision)>--->

<cffile action="write" nameconflict="overwrite" 
destination="D:\Inetpub\Var\wirez\www.wirez.com\website\testserver\" 
output="#New_File#">

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:15:642
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