Saving bitmap image from clipboard to file

Question

I managed to save an image from clipboard to file using:

if Clipboard.HasFormat(CF_BITMAP) then begin
   Image1.Picture.Assign(Clipboard);
   Image1.Picture.SaveToFile('c:\test\abc.bmp');
end;

How do I get it to save to a different file name and not overwrite the existing one (say abc, abc1, abc2, etc.)?

Answer

Here's a Delphi Source code example for storing up to 10000 images under the same "base name".
Just increase the MaxFiles number if that is not enough ;)

Procedure ...;
const
  BaseName = 'c:\test\abc';
  MaxFiles = 10000;
var
  i: integer;
  FileName: string;
begin
  ...
  for i := 1 to MaxFiles do begin
    FileName := BaseName + IntToStr(i) + '.bmp';
    if not FileExists(FileName) then begin
      Image1.Picture.SaveToFile(FileName);
      break;
    end;  
  end;
  ...
end;