Changing whole folder - a scripting fail

Hello everyone!

I am fairly new to using ImageJ Macros. I wanted to apply changes to all images inside a folder. There are two wonderful tutorials on the imagej website.
I used the one from “Batch Processing”

However, the script applies all commands to the first image and overwrites all the others with that first output and saves the results in the folder above the folder I put in the dialog…
If someone could please point me on the mistake I am doing that would be great!

I have added my script and the macro log!

Since I just used the example from the website I am quite confused about this result.

Thanks for any help in advance!

Log.txt (4.4 KB)

Hey Konstantin @WelcomeKon,

can you try to print out the filename you are opening to check if it’s the right filename?


Let us know if this helps!


Hey Robert,

thanks for the quick answer!
I added the print statement before the open statement.

It now prints the following (I created a short test file and directory: images_1-4):

The log mentions image_4 before each processing step, but only saves image_1 , but prints “processing image_x”.

So there might be an issue with the input line.

When I use the ImageJ in-build batch command via “Proces/Batch/Macro…” and add my command in the dialog, it all works fine. Applies the changes as I want them and saves in the right directory :upside_down_face:
While it allows for the solution I need, I would like to know what I am doing wrong to improve for further situations.

I think your script prints out the folder over and over and no filename, right?

Can you try to open the image like you save it?

open(input + file);

Alternatively, try

open(input + File.separator + file);

Let us know if this helps!


1 Like