ON RULE BEGIN PASCAL SCRIPT: Var iList: Integer; tmpFilename: String; tmpList: TstringList; Const ctSearchPath = 'C:\Test\Search\'; // Must end with a \ ctSearchFilter = '*.pregen'; ctSearchSubFolders = False; // False or True Begin psExitCode:= 0; psVSA := ''; psVSB := ''; // ... add your code here tmpList := psListFilesEx(ctSearchPath, ctSearchFilter, ctSearchSubFolders); Try For iList := 0 to (tmpList.Count-1) Do Begin tmpFilename := tmpList.Strings[iList]; psVSB := psVSB + tmpFilename + ';'; // Delete pregen file(s) afterwards tmpFilename := ExtractFilename(tmpFilename); tmpFilename := ChangeFileExt(tmpFilename, '.pdf'); psVSA := psVSA + tmpFilename + ';'; // Filename Include filter End; Finally tmpList.Free; End; // Debug psLogWrite(1, '', 'Filename filter as psVSA: ' + psVSA); // Set psExitCode If Not (psVSA = '') Then psExitCode := 1; End. ON RULE END PASCAL SCRIPT: Var iList: Integer; tmpFile: String; tmpList: TStringList; Begin psExitCode:= 1; // ... add your code here IF Not (psVSB = '') Then Begin If (psCurrentFilesSrcError = 0) And (psCurrentFilesDstError = 0) And (psCurrentControlSrcError = 0) And (psCurrentControlDstError = 0) Then Begin tmpList := TStringList.Create; Try tmpList.StrictDelimiter := True; tmpList.QuoteChar := #0; tmpList.Delimiter := ';'; tmpList.DelimitedText := psVSB; // Iterate For iList := 0 to (tmpList.Count-1) Do Begin tmpFile := tmpList.Strings[iList]; psLogWrite(1, '', 'Delete pregen file: ' + tmpFile); DeleteFile(tmpFile); End; Finally tmpList.Free; End; End Else psLogWrite(1, '', 'Error occured so we will not delete the pregen file(s)'); End; End.