Author: Jonas Bilinkevicius How to delete multiple files from a directory Answer: 1 procedure DeleteFiles(sMask, sPath: string); 2 var 3 SearchRec: TSearchRec; 4 Found: Integer; 5 begin 6 sPath := IncludeTrailingPathDelimiter(sPath); 7 Found := SysUtils.FindFirst(sPath + sMask, faAnyFile, SearchRec); 8 try 9 while (Found = 0) do 10 begin 11 if not (SearchRec.Attr and faDirectory > 0) then 12 SysUtils.DeleteFile(sPath + SearchRec.Name); 13 Found := SysUtils.FindNext(SearchRec); 14 end; 15 finally 16 SysUtils.FindClose(SearchRec); 17 end; 18 end; 19 20 //Usage: 21 22 DeleteFiles('*.txt', 'c:\myfiles');