http://imagej.273.s1.nabble.com/Weird-naming-behavior-of-the-batchMode-tp5024649p5024650.html
This is the expected behavior. Opened images with duplicate names are not renamed if they are not displayed. It is a good idea to avoid using image names to select images. Instead, use image IDs or image indexes. The following example macro opens and processes three copies of the blobs sample image.
> On May 2, 2021, at 1:47 PM, CARL Philippe (LBP) <
[hidden email]> wrote:
>
> Dear all,
> In the case I launch the following macro:
> run("Blobs (25K)");
> run("Blobs (25K)");
> run("Blobs (25K)");
> I will get 3 pictures named "blobs.gif", "blobs-1.gif" and "blobs-2.gif".
> And "blobs-3.gif", "blobs-4.gif" and "blobs-5.gif" in the case I launch the code again.
> But I the case I lauch the following macro code:
> setBatchMode(true);
> run("Blobs (25K)");
> run("Blobs (25K)");
> run("Blobs (25K)");
> setBatchMode("exit and display");
> The 3 outputted pictures will all have the name "blobs.gif".
> And in the case I launch the macro a second time, I get 1 picture named "blobs-1.gif" and 2 pictures named "blobs.gif".
> And if I launch it a third time, I get 1 picture named "blobs-2.gif" and 2 pictures named "blobs.gif" and so on.
> Have a nice end of week-end.
> My best regards,
> Philippe