Delete log files older than 20 Days

  • Posts: 9
  • Thank you received: 0

Delete log files older than 20 Days was created by Emiliano

Hello

I have a requirement to delete data transformation logs older than 20 days old.
Can I do this with Visual Importer ETL

Emiliano
8 years 11 months ago #4640

Please Log in or Create an account to join the conversation.

  • Posts: 8018
  • Karma: 33
  • Thank you received: 502

Replied by admin on topic Re: Delete log files older than 20 Days

Hello

Something like this should do

var i: integer;
Rec : TSearchRec;
Attr : integer;
SearchDirectory,Mask : string;
begin
SearchDirectory:='c:\';
Mask:='*.csv';
Attr := faReadOnly+faHidden+faArchive+faAnyFile;
if FindFirst(SearchDirectory+Mask,Attr,Rec) = 0 then
try
repeat
if ((Rec.Name='..') or (Rec.Name='.'))=false then
begin
if FormatDateTime('YYYY-MM-DD',FileDateToDateTime(FileAge(SearchDirectory+Rec.Name)))<FormatDateTime('YYYY-MM-DD',now-30) then
DeleteFile(SearchDirectory+Rec.Name);
end;
until FindNext(Rec) <> 0;
finally
FindClose(Rec);
end;
result:=true;
end;

George
Mike
8 years 11 months ago #4641

Please Log in or Create an account to join the conversation.

  • Posts: 12
  • Thank you received: 0

Replied by keiooz on topic Re: Delete log files older than 20 Days

What actually happens if you won't delete your logs older than 20 days?
Went down deep!!
8 years 10 months ago #4707

Please Log in or Create an account to join the conversation.

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies