WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Operations

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Copying Files from a Given Date

Keywords: 

Question:

I could use some help to perform the following:
  1. Check files from our log directory from today back seven days.

  2. Copy these 7 days worth of files into one file (file combine).
I am looking for any files - *.log I want Winbatch to find the last 7 days worth of *.log on any given day it is run. Any help would be greatly appreciated!

Answer:

Try...
AddExtender("Wsrch34I.dll");Searcher Extender DLL

timenow=TimeYmdHms() ;get current datetime
hand=srchInit("C:\Program Files\ositis Software\winproxy\logs","*.log","","",16) ;initializes your search

while 1
   file=srchNext(hand);gets first file
   if file=="" then break ;if no more files break out of while loop
   
   timenow=TimeYmdHms();gets todays date   
   getfiletime=FileYmdHms(file);gets file time
   if TimeDeffDays(timenow,getfiletime) > 7 then continue ; too old

   FileAppend(file, "C:\Program Files\ositis Software\winproxy\logs\winproxyweekly.txt") ;copies the file
endwhile

srchFree(hand); frees search handle
Message("File Delete", "Completed.")

Article ID:   W13228
Filename:   Copying Files from a Given Date.txt
File Created: 2001:03:01:14:45:38
Last Updated: 2001:03:01:14:45:38