Var tmpList: TStringList; Const ctFileFilter = '*.pdf'; // File Include Filter ctInclSubDir = False; // Do not include search in subfolder Begin // Init var psVSA := ''; psExitCode:= 0; tmpList := Nil; // ... add your code here tmpList := psListFilesEx(psFilePath, ctFileFilter, ctInclSubDir); If Assigned(tmpList) Then Begin tmpList.StrictDelimiter := True; tmpList.Delimiter := ';'; tmpList.QuoteChar := #0; // Debug psLogWriteStr('Files Found: ' + tmpList.DelimitedText); If tmpList.Count > 0 Then Begin psVSA := tmpList.DelimitedText; psExitCode := 1; End; // Free List Object tmpList.Free; End; End. Var iList: Integer; tmpFile: String; tmpList: TStringList; Begin // Init var psExitCode:= 1; // ... add your code here If psVSA <> '' Then Begin tmpList := TStringList.Create; Try tmpList.StrictDelimiter := True; tmpList.Delimiter := ';'; tmpList.QuoteChar := #0; tmpList.DelimitedText := psVSA; // Debug psLogWriteStr('Files to Delete: ' + tmpList.DelimitedText); // Iterate Files For iList := 0 to (tmpList.Count - 1)Do Begin tmpFile := tmpList.Strings[iList]; If Trim(tmpFile) <> '' Then Begin If DeleteFile(tmpFile) Then Begin psLogWriteStr('Deleted '+ tmpFile + ' Successfully'); End Else Begin psLogWriteStr('Delete '+ tmpFile + ' Error'); psExitCode := 0; End; End; End; Finally tmpList.Free; End; End; End.