Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    West Monroe, LA
    Posts
    294

    Delete OLD files

    I am trying to compare the date of a list of files (each file) to the current date. If it's older than 60 day's I want to delet it. I can't figure out how to compare the dates. I can get the CreationDateISO but it has the time, and the File.Attributes Date is different. I'm comfused
    SELECT * FROM Users WHERE IQ > 0;
    o rows Returned

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    2 years too late... but

    Code:
    function File.Age( cFile )
    	local nNow = String.Replace(System.GetDate(DATE_FMT_ISO), "-", "", false);
      local cDate = String.Replace(File.GetAttributes(cFile).CreationDateISO,"-","",false);
      local nT = String.Find(cDate, "t", 1, false)
    	local nFile = String.ToNumber(  String.Left(cDate,nT-1) )
    
      return Math.Abs(nNow-nFile)
    end


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    Silly me -- this really isn't right at all!
    This doesn't take into account that days only go to 30 and months only to 12.... Late night yesterday... disregard that function....


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  4. #4
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    Here's a version that will probably work for most... You can take it from here to be more specific to each month's days.

    Code:
    function File.AgeInDays( cFile )
      -- This uses averages of:
      -- 365.25 days per year
      -- 30.44 days per month (365.24 days per year/12 months)
      -- Becuase of this; it's not 100% accurate.
      
      local cNow = String.Replace(System.GetDate(DATE_FMT_ISO), "-", "", false);
      local cDate = String.Replace(File.GetAttributes(cFile).WriteDateISO,"-","",false);
      local nT = String.Find(cDate, "t", 1, false)
      local cFile =  String.Left(cDate,nT-1)
    
      local nFileY = String.Left(cFile,4)
      local nFileM = String.Mid(cFile,5,2)
      local nFileD = String.Right(cFile,2)
    
      local nNowY = String.Left(cNow,4)
      local nNowM = String.Mid(cNow,5,2)
      local nNowD = String.Right(cNow,2)
    
      local nFileDays = Math.Ceil( (nFileY*365.25) + (nFileM * 30.44) + nFileD )
      local nNowDays = Math.Ceil( (nNowY*365.25) + (nNowM * 30.44) + nNowD )
    
      return Math.Abs( nNowDays - nFileDays )
    end


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

Similar Threads

  1. delete legacy files
    By zebra in forum Visual Patch 2.0
    Replies: 3
    Last Post: 01-30-2007, 08:52 AM
  2. Delete all files in folder using wildcard
    By SGW in forum AutoPlay Media Studio 6.0
    Replies: 28
    Last Post: 12-06-2005, 07:52 AM
  3. Unable to find software?
    By NigelLacey in forum Visual Patch 2.0
    Replies: 4
    Last Post: 10-11-2005, 10:35 AM
  4. SUF 6.0 - Action, Delete files
    By Romahe in forum Setup Factory 6.0
    Replies: 4
    Last Post: 04-03-2002, 03:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts