Copying Files from a Given Date
Keywords:
Question:
I could use some help to perform the following:
- Check files from our log directory from today back seven days.
- 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