How to check if there is an image with the same file name?

I want to save images without overwriting them. This is my code:

  if (controlDown) {
    if (keyCode == 83) {  
      PImage partialSave = get(0,0,1098,650);
      nimg++;
      partialSave.save("drawings/draw"+nimg+".jpg");
    }

Is this a question? Does it work?

It would work, imho

But when you start your Sketch anew (new session ), the old images would be overwritten

So let the Sketch check the last highest number first

That’s what I’m asking, how can i check the highest number?

1 Like

Check out the post from gotoloop please

In theory you can use fileList scan all names and receive the highest number by a search

Then add +1

fileList worked!!, ty all!

1 Like